首页 > 其他 > 详细

简单好用的小控件------自定义checkbox

时间:2015-03-03 18:39:42      阅读:156      评论:0      收藏:0      [点我收藏+]

技术分享

1.首先在drawable文件夹中添加drawable文件checkbox_style.xml。

[html] view plaincopy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <selector xmlns:android="http://schemas.android.com/apk/res/android">  
  3.   
  4.     <item android:drawable="@drawable/checkbox_pressed" android:state_checked="true"/>  
  5.     <item android:drawable="@drawable/checkbox_normal" android:state_checked="false"/>  
  6.     <item android:drawable="@drawable/checkbox_normal"/>  
  7.   
  8. </selector>  
2.在values文件夹下的styles.xml文件中添加CustomCheckboxTheme样式。

[html] view plaincopy
  1. <style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">  
  2.     <item name="android:button">@drawable/checkbox_style</item>  
  3. </style>  
3.在布局文件中使用CustomCheckboxTheme样式。

[html] view plaincopy
  1. <CheckBox  
  2.         android:id="@+id/select_all"  
  3.         android:layout_width="wrap_content"  
  4.         android:layout_height="wrap_content"  
  5.         style="@style/CustomCheckboxTheme" />  


简单好用的小控件------自定义checkbox

原文:http://blog.csdn.net/fangchao3652/article/details/44040387

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!