欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android View背景選擇器編寫技巧

 更新時(shí)間:2017年02月27日 12:09:22   作者:道郭  
本文主要介紹了Android View背景選擇器編寫技巧,具有很好的參考價(jià)值,下面跟著小編一起來看下吧
  1. 在項(xiàng)目中選擇器的使用是非常多的,以下是本人在項(xiàng)目中的一些常用的背景選擇器的寫法
  2. 帶邊框下劃線背景選擇器效果圖:

上面布局中放了10個(gè)CheckBox,然后設(shè)置了CheckBox的背景圖片位,背景選擇器,同時(shí)設(shè)置了字體的顏色選擇器。

帶邊框下劃線背景選擇器代碼:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- 選中狀態(tài) -->
  <item android:state_checked="true">
    <!-- 設(shè)置層次背景 -->
    <layer-list>
      <!-- 底層 -->
      <item>
        <shape android:shape="rectangle"><!-- 畫矩形 -->
          <!--邊框色-->
          <stroke android:width="1dp" android:color="@color/gray27"/>
          <!-- 背景色 -->
          <solid android:color="@color/gray17"/>
          <!-- 圓角 -->
          <corners android:radius="3dp"/>
        </shape>
      </item>
      <!-- 上層 -->
      <item android:top="36.5dp"> 
      <!-- top:距離頂部多少db開始畫線,需配合View的高度繪制 -->
        <shape android:shape="rectangle">
          <solid android:color="@color/mainColor"/>
        </shape>
      </item>
    </layer-list>
  </item>
  <!-- 默認(rèn)狀態(tài) -->
  <item>
    <shape>
      <stroke android:width="1dp" android:color="@color/gray27"/>
      <solid android:color="@color/white"/>
      <corners android:radius="@dimen/radius"/>
    </shape>
  </item>
</selector>

字體選擇器代碼:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_checked="true" android:color="@color/mainColor" />
  <item android:color="@color/textColor54" />
</selector>

邊框背景選擇器效果圖:

邊框背景選擇器實(shí)現(xiàn)代碼:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_checked="true">
    <shape >
      <stroke android:width="1dp" android:color="@color/mainColor"/>
      <solid android:color="@color/gray17"/>
      <!-- 圓角 -->
      <corners android:radius="@dimen/radius"/>
    </shape>
  </item>
   <item>
    <shape>
      <stroke android:width="1dp" android:color="@color/gray27"/>
      <solid android:color="@color/white"/>
      <corners android:radius="@dimen/radius"/>
    </shape>
  </item>
</selector>

-- 不帶邊框下劃線背景選擇器效果圖:

不帶邊框下劃線背景選擇器實(shí)現(xiàn)代碼:

<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android="http://schemas.android.com/apk/res/android" >
  <item android:state_checked="true">
    <layer-list>
      <item android:top="36.5dp">
        <shape android:shape="rectangle" >
          <solid android:color="@color/mainColor" />
        </shape>
      </item>
    </layer-list>
  </item>
  <item android:drawable="@color/transColor" />
</selector>

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

  • Android系統(tǒng)自帶分享圖片功能

    Android系統(tǒng)自帶分享圖片功能

    這篇文章主要為大家詳細(xì)介紹了Android系統(tǒng)自帶分享圖片功能,圖片分享的工具類,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • 淺談android @id和@+id的區(qū)別

    淺談android @id和@+id的區(qū)別

    這篇文章主要介紹了淺談android @id和@+id的區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09
  • 在Android打包中區(qū)分測(cè)試和正式環(huán)境淺析

    在Android打包中區(qū)分測(cè)試和正式環(huán)境淺析

    這篇文章主要給大家介紹了關(guān)于在Android打包中如何區(qū)分測(cè)試和正式環(huán)境的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起看看吧。
    2017-10-10
  • Android自定義控件仿QQ編輯和選取圓形頭像

    Android自定義控件仿QQ編輯和選取圓形頭像

    這篇文章主要為大家詳細(xì)介紹了Android自定義控件編輯和選取圓形頭像,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-09-09
  • Android數(shù)據(jù)加密之異或加密算法的實(shí)現(xiàn)方法

    Android數(shù)據(jù)加密之異或加密算法的實(shí)現(xiàn)方法

    下面小編就為大家?guī)硪黄狝ndroid數(shù)據(jù)加密之異或加密算法的實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2016-10-10
  • Android 快速搭建FTP服務(wù)器的方法

    Android 快速搭建FTP服務(wù)器的方法

    這篇文章主要介紹了Android如何搭建FTP服務(wù)器,需要的朋友可以參考下
    2017-08-08
  • kotlin 官方學(xué)習(xí)教程之基礎(chǔ)語法詳解

    kotlin 官方學(xué)習(xí)教程之基礎(chǔ)語法詳解

    這篇文章主要介紹了kotlin 官方學(xué)習(xí)教程之基礎(chǔ)語法詳解的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • Android?中?FrameLayout?布局及屬性的使用詳解

    Android?中?FrameLayout?布局及屬性的使用詳解

    這篇文章主要介紹了Android?中?FrameLayout?布局及屬性的使用,FrameLayout?在實(shí)現(xiàn)簡(jiǎn)單布局時(shí)非常方便,特別適用于疊加式布局,如顯示疊加的圖層或浮動(dòng)按鈕等,需要的朋友可以參考下
    2024-03-03
  • OpenGL ES正交投影實(shí)現(xiàn)方法(三)

    OpenGL ES正交投影實(shí)現(xiàn)方法(三)

    這篇文章主要為大家詳細(xì)介紹了OpenGL ES正交投影的實(shí)現(xiàn)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • Android 測(cè)量文字寬度的實(shí)例方法

    Android 測(cè)量文字寬度的實(shí)例方法

    在本篇文章里小編給大家整理了關(guān)于Android 測(cè)量文字寬度的實(shí)例方法,需要的朋友們可以參考學(xué)習(xí)下。
    2020-02-02

最新評(píng)論