Android 自定义CheckBox样式
来源:互联网 发布:centos 7 route add 编辑:程序博客网 时间:2024/05/19 13:43
尊重原创成果,转载注明出处!
原文地址:http://wsy1983wsy.iteye.com/blog/1471573
1、首先res/drawable中定义编写如下样式:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/check_true" android:state_checked="true"></item>
<item android:drawable="@drawable/check_true" android:state_selected="true"></item>
<item android:drawable="@drawable/check_true" android:state_pressed="true"></item>
<item android:drawable="@drawable/check_false"></item>
</selector>
2、在layout中添加checkbox控件:
<CheckBox
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/btn_check"
android:button="@null"
android:checked="true"/>
如果CheckBox除了按钮还有图片的话就要按下面的代码设置checkBox了!
<CheckBox
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/btn_check"
android:button="@null"
android:checked="true"/>
其中drwable/btn_check为1中顶一个文件名称,另外必须将android:button设置为@null。
@drawable/check_true和@drawable/check_false为checkbox不同状态的图片,可自行设计。
- android CheckBox 自定义样式
- Android 自定义CheckBox 样式
- android 自定义checkbox 样式
- Android 自定义CheckBox样式
- Android自定义checkbox样式
- android 自定义checkbox 样式
- 自定义Checkbox样式--Android
- Android 自定义CheckBox 样式
- Android自定义CheckBox样式
- android自定义checkBox样式
- Android 自定义checkbox样式
- Android 自定义CheckBox样式
- Android 自定义CheckBox样式
- Android中自定义checkbox样式
- Android中自定义checkbox样式
- android中checkbox自定义样式
- Android 自定义Checkbox显示样式
- Android中自定义checkbox样式
- C++ time and date
- 机器学习笔记之线性回归
- Java中JDK,JRE,JVM的区别
- 6.块属性 子集默认宽度为父级的宽度
- soft raid5阅读笔记之四--读成员磁盘错误的处理
- Android 自定义CheckBox样式
- Hadoop and Spark and Hive Installation
- 从程序员到项目经理(二十二):以德服人才能口服心服
- c++中的图链表数据结构
- Oracle数据库操作及函数命令总结
- Scala class和case class的区别
- day_10-acm 不定长数组 -vector
- 小记——linux信号
- 挑战程序设计解题报告 2.6.1辗转相除法