Android自定義簡單的頂部標(biāo)題欄-創(chuàng)新互聯(lián)

本文實(shí)例為大家分享了Android實(shí)現(xiàn)簡單頂部標(biāo)題欄的具體代碼,供大家參考,具體內(nèi)容如下

大竹網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,大竹網(wǎng)站設(shè)計制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為大竹數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)要多少錢,請找那個售后服務(wù)好的大竹做網(wǎng)站的公司定做!

實(shí)現(xiàn)功能:

1)自定義View標(biāo)題欄布局;

2)靈活的可以自己傳入類型,選擇所需要的控件來顯示隱藏

3)相對于我之前寫過的一篇,免繼承,可直接在布局里使用

4)直接可以在布局控件里設(shè)置屬性

老規(guī)矩,上幾張效果圖:

由效果圖可見,這個是可以根據(jù)傳入type來控制,比較靈活的

下面就來實(shí)現(xiàn)以下步驟,最后我會貼上源碼

1.創(chuàng)建一個布局文件,命名,layout_titlebar,來部署我們的標(biāo)題欄樣式,可以自定義更改,圖片文件可暫時用自己的替代

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="50dp">
 
  <ImageView
    android:id="@+id/iv_back"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_marginLeft="20dp"
    android:src="@drawable/icon_back"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
 
  <TextView
    android:id="@+id/tv_title"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="標(biāo)題"
    android:textColor="#000"
    android:textSize="16sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
 
  <TextView
    android:id="@+id/tv_more"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="更多"
    android:textColor="#000"
    android:textSize="16sp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
 
  <ImageView
    android:id="@+id/iv_more"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:src="@drawable/icon_more"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent" />
 
</android.support.constraint.ConstraintLayout>

當(dāng)前標(biāo)題:Android自定義簡單的頂部標(biāo)題欄-創(chuàng)新互聯(lián)
URL地址:http://bm7419.com/article36/dssopg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)小程序開發(fā)、網(wǎng)站維護(hù)建站公司、域名注冊網(wǎng)站設(shè)計

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計公司