欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

AndroidView背景選擇器編寫技巧

  1. 在項目中選擇器的使用是非常多的,以下是本人在項目中的一些常用的背景選擇器的寫法
  2. 帶邊框下劃線背景選擇器效果圖:

Android View背景選擇器編寫技巧

成都創(chuàng)新互聯(lián)公司專業(yè)為企業(yè)提供田林網(wǎng)站建設、田林做網(wǎng)站、田林網(wǎng)站設計、田林網(wǎng)站制作等企業(yè)網(wǎng)站建設、網(wǎng)頁設計與制作、田林企業(yè)網(wǎng)站模板建站服務,十載田林做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡服務。

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

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

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <!-- 選中狀態(tài) -->
  <item android:state_checked="true">
    <!-- 設置層次背景 -->
    <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>
  <!-- 默認狀態(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>

邊框背景選擇器效果圖:

Android View背景選擇器編寫技巧

邊框背景選擇器實現(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>

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

Android View背景選擇器編寫技巧

不帶邊框下劃線背景選擇器實現(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>

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學習或者工作能帶來一定的幫助,同時也希望多多支持創(chuàng)新互聯(lián)!

文章名稱:AndroidView背景選擇器編寫技巧
標題路徑:http://www.chinadenli.net/article46/ighghg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設計商城網(wǎng)站域名注冊App設計搜索引擎優(yōu)化面包屑導航

廣告

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

成都定制網(wǎng)站建設