安卓selector

定义styles.xml

Xml代码  收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3. <style name="RoundedCornerBtn" parent="RoundedCornerView">  
  4.         <item name="android:background">@drawable/roundedcorner_btn</item>  
  5.         <item name="android:gravity">left|center_vertical</item>  
  6.         <item name="android:textColor">@android:color/black</item>  
  7.   
  8. </style>  
  9. </resources>  

 roundedcorner_btn.xml

Xml代码  收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android" >  
  3.     <item android:state_pressed="true" >  
  4.         <shape>  
  5.               <stroke android:width="2dp" android:color="@color/orange" />  
  6.               <corners android:radius="10dp" />  
  7.               <solid android:color="@color/orange"/>  
  8.         </shape>  
  9.     </item>  
  10.     <item android:state_focused="true">  
  11.         <shape>  
  12.     <stroke android:width="2dp" android:color="@color/light_gray" />  
  13.     <corners android:radius="10dp" />  
  14.     <solid android:color="@android:color/white"/>  
  15.         </shape>  
  16.     </item>  
  17.     <item >  
  18.         <shape>  
  19.     <stroke android:width="2dp" android:color="@color/light_gray" />  
  20.     <corners android:radius="10dp" />  
  21.     <solid android:color="@android:color/white"/>  
  22.     </shape>  
  23.     </item>  
  24.   
  25. </selector>  

 color.xml

Xml代码  收藏代码
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <resources>  
  3.     <color name="tabMedium">#2B2B2B</color>  
  4.     <color name="tabDark">#000000</color>  
  5.     <color name="tabTransparent">#10ffffff</color>  
  6.     <color name="trans">#0000</color>  
  7.     <color name="gray">#FF999999</color>  
  8.     <color name="light_gray">#FFCCCCCC</color>  
  9.     <color name="light_blue">#FFC5CCD4</color>  
  10.     <color name="blue">#0099FF</color>  
  11.     <color name="orange">#fff48b01</color>  
  12. </resources>  

 这些都是我从项目里面copy出来的,如果有问题可以找我要相应的代码

【推广】 免费学中医,健康全家人
原文地址:https://www.cnblogs.com/lucky-star-star/p/4063396.html