偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

Android通用標(biāo)題欄組合控件

移動(dòng)開發(fā) Android
由于項(xiàng)目中經(jīng)常用到此種組合控件,就封裝了下,具體效果看下圖,老司機(jī)可以繞道哈!

由于項(xiàng)目中經(jīng)常用到此種組合控件,就封裝了下,具體效果看下圖,老司機(jī)可以繞道哈!   

 

一、主要功能

  • 支持左右圖標(biāo)動(dòng)態(tài)設(shè)置
  • 支持左右、中間文字動(dòng)態(tài)修改
  • 支持字體大小、顏色修改
  • 支持左右圖標(biāo),左中右文字隱藏顯示
  • 支持左右圖標(biāo)和文案的點(diǎn)擊監(jiān)聽

二、基本使用方式

  1. <com.example.android.customvView.CustomNavigatorBar 
  2.  
  3.         android:id="@+id/customView" 
  4.  
  5.         android:layout_width="match_parent" 
  6.  
  7.         android:layout_height="wrap_content" 
  8.  
  9.         app:leftImage="@drawable/leftarrow" 
  10.  
  11.         app:rightImage="@drawable/rightarrow" 
  12.  
  13.         app:leftImageVisiable="true" 
  14.  
  15.         app:rightImageVisible="true" 
  16.  
  17.         app:leftText="左邊" 
  18.  
  19.         app:rightText="右邊" 
  20.  
  21.         app:midText="標(biāo)題" 
  22.  
  23.         app:midTextFontColor="#ffffff" 
  24.  
  25.         app:leftTextColor="#ffffff" 
  26.  
  27.         app:rightTextColor="@color/colorAccent" 
  28.  
  29.         app:titleBarBackground="@color/colorPrimary" 
  30.  
  31.         app:midTextFontSize="18px" 
  32.  
  33.         app:leftTextVisibale="true" 
  34.  
  35.         app:rightTextVisible="true" 
  36.  
  37.         app:leftTextFontSize="16px" 
  38.  
  39.         app:rightTextFontSize="16px" 
  40.  
  41.         />  

三、基本屬性介紹

屬性名 屬性說明 屬性值
titleBarBackground 標(biāo)題欄背景色 color,reference,默認(rèn)為white
leftImage 左邊圖片 reference
leftImageVisiable 左邊圖片是否可見 boolean,默認(rèn)為true,顯示控件
leftText 左邊文案 string,reference
leftTextVisibale 左邊文案是否可見 boolean,默認(rèn)為true,顯示控件
leftTextFontSize 左邊文案字體大小 dimension,reference,默認(rèn)為16sp
leftTextColor 左邊文案字體顏色 color,reference
midText 中間文案 string,reference
midTextVisiable 中間文案是否可見 boolean,默認(rèn)為true,顯示控件
midTextFontSize 中間文案字體大小 dimension,reference,默認(rèn)為18sp
midTextFontColor 中間文案字體顏色 color,reference
rightText 右邊文案 color,reference
rightTextVisible 右邊文案是否可見 boolean,默認(rèn)為true,顯示控件
rightTextFontSize 右邊文案字體大小 dimension,reference,默認(rèn)為16sp
rightTextColor 右邊文案字體顏色 color,reference
rightImage 右邊圖片 reference
rightImageVisible 右邊圖片是否可見 boolean,默認(rèn)為true,顯示控件

四、組合控件類   

    

  

 

  

 

 

  

 

五、attrs.xml 

  1. <?xml version="1.0" encoding="utf-8" ?> 
  2.  
  3. <resources> 
  4.  
  5.     <declare-styleable name = "CustomNavigatorBar"
  6.  
  7.         <attr name="titleBarBackground" format="reference|color" /> 
  8.  
  9.         <attr name="leftImage" format="reference" /> 
  10.  
  11.         <attr name="leftImageVisiable" format="boolean" /> 
  12.  
  13.         <attr name="leftText" format="string|reference" /> 
  14.  
  15.         <attr name="leftTextVisibale" format="boolean" /> 
  16.  
  17.         <attr name="leftTextFontSize" format="dimension|reference" /> 
  18.  
  19.         <attr name="leftTextColor" format="color|reference" /> 
  20.  
  21.         <attr name="midText" format="string|reference" /> 
  22.  
  23.         <attr name="midTextVisiable" format="boolean" /> 
  24.  
  25.         <attr name="midTextFontSize" format="dimension|reference" /> 
  26.  
  27.         <attr name="midTextFontColor" format="color|reference" /> 
  28.  
  29.         <attr name="rightText" format="string|reference" /> 
  30.  
  31.         <attr name="rightTextVisible" format="boolean" /> 
  32.  
  33.         <attr name="rightTextFontSize" format="dimension|reference" /> 
  34.  
  35.         <attr name="rightTextColor" format="color|reference" /> 
  36.  
  37.         <attr name="rightImage" format="reference" /> 
  38.  
  39.         <attr name="rightImageVisible" format="boolean" /> 
  40.  
  41.     </declare-styleable> 
  42.  
  43. </resources>  

六、組合控件布局(custom_title_bar.xml)

為什么使用merge,因?yàn)榻M合控件已經(jīng)extends RelativeLayout,如果根布局還是用viewGroup的話,會(huì)使布局重復(fù)嵌套,影響View的繪制性能; 

 

七、具體使用

  1.  CustomNavigatorBar customNavigatorBar = (CustomNavigatorBar) findViewById(R.id.customView); 
  2.         /** 
  3.  
  4.          * 第一種監(jiān)聽的具體實(shí)現(xiàn) 
  5.  
  6.          */ 
  7.  
  8.         customNavigatorBar.setLeftImageOnClickListener(new View.OnClickListener() { 
  9.  
  10.             @Override 
  11.  
  12.             public void onClick(View view) { 
  13.  
  14.                 Toast.makeText(MainActivity.this,"left",Toast.LENGTH_SHORT).show(); 
  15.  
  16.             } 
  17.  
  18.         }); 
  19.  
  20.  
  21.         /** 
  22.  
  23.          * 第二種監(jiān)聽的具體實(shí)現(xiàn) 
  24.  
  25.          */ 
  26.  
  27.         customNavigatorBar.addViewClickListener(new CustomNavigatorBar.OnCustomClickListener() { 
  28.  
  29.             @Override 
  30.  
  31.             public void onClickListener(View rootView) { 
  32.  
  33.                 switch (rootView.getId()) { 
  34.  
  35.                     case R.id.right_image: 
  36.  
  37.                         Toast.makeText(MainActivity.this,"right_image is clicked",Toast.LENGTH_SHORT).show(); 
  38.  
  39.                         break ; 
  40.  
  41.                     case R.id.left_image: 
  42.  
  43.                         Toast.makeText(MainActivity.this,"left_image is clicked",Toast.LENGTH_SHORT).show(); 
  44.  
  45.                         break ; 
  46.  
  47.                 } 
  48.  
  49.             } 
  50.  
  51.         });  
責(zé)任編輯:龐桂玉 來源: 安卓巴士Android開發(fā)者門戶
相關(guān)推薦

2011-02-22 14:53:41

titlebar標(biāo)題欄Android

2017-05-03 16:30:38

AndroidScrollView滾動(dòng)視圖

2011-05-04 10:40:02

網(wǎng)頁加載進(jìn)度標(biāo)題欄lephone

2015-08-14 17:47:35

Windows 10標(biāo)題欄

2009-11-03 18:05:00

VB.NET窗體標(biāo)題欄

2013-12-19 14:16:46

Android ApiAndroid開發(fā)Android SDK

2023-06-26 07:21:41

標(biāo)題欄鼠標(biāo)標(biāo)題

2022-02-13 19:05:19

微軟Windows 11

2021-09-01 13:53:19

WindowsAcrylic標(biāo)題欄

2021-04-23 15:20:54

微軟瀏覽器Windows

2022-02-21 08:31:58

Windows 11微軟云母視覺

2010-08-05 14:01:19

評(píng)測Android開發(fā)iPhone開發(fā)

2021-03-14 10:32:23

微軟Edge瀏覽器

2012-12-27 15:29:33

Android開發(fā)Activity

2021-06-03 05:08:19

Edge微軟瀏覽器

2010-08-04 15:01:07

Flex Panel控

2023-05-17 10:14:37

谷歌Chrome瀏覽器

2023-05-17 14:59:08

Windows 11Chrome 瀏覽

2021-05-31 10:36:38

EdgeWindows標(biāo)簽

2011-04-20 10:58:34

Java
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)