android自定义checkBox样式
来源:互联网 发布:windows聚焦图片来源 编辑:程序博客网 时间:2024/05/19 13:59
<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">大部分情况下,并不需要自定义控件,只需要设置一下checkBox的属性就可以了,</span>
第一种方法:
第一步:定义drawable样式文件
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/checked" android:state_checked="true" /> <item android:drawable="@drawable/checked_false" android:state_checked="false" /> <item android:drawable="@drawable/checked" android:state_pressed="true" /> <item android:drawable="@drawable/checked_false" /></selector>
第二步:定义一个style
<style name="checkBoxStyle"> <item name="android:button">@drawable/checkbox_style</item> </style>
定义的是android:button属性,值是我们刚才定义的drawable
第三步:在xml配置文件中使用这个style
<CheckBox android:id="@+id/checkBox" android:layout_width="25dp" android:layout_height="25dp" android:layout_gravity="center" style="@style/checkBoxStyle" android:layout_marginLeft="10dp" />
第二种方法:
第一步:定义drawable样式文件
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/checked" android:state_checked="true" /> <item android:drawable="@drawable/checked_false" android:state_checked="false" /> <item android:drawable="@drawable/checked" android:state_pressed="true" /> <item android:drawable="@drawable/checked_false" /></selector>
第二步:在xml文件中配置
<CheckBox android:id="@+id/checkBox" android:layout_width="25dp" android:layout_height="25dp" android:layout_gravity="center" android:background="@drawable/checkbox_style" android:button="@null" android:layout_marginLeft="10dp" />
这种方法,不用设置style了,直接设置的是background属性,然后,把button属性设置为@null
0 0
- 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样式
- 设计程序,用数码管显示按键编号
- 腾讯公司将为您检测密码强度,防止QQ被盗,请您输入密码
- android自定义view实现流式布局(FlowLayout)和热门标签
- 关于单片机测量信号频率的精度问题
- 用汇编语言编八路彩灯控制系统(流水灯)
- android自定义checkBox样式
- 计时秒表程序设计
- MCS-51单片机中断测试系统设计
- 处理不确定数据的方法研究
- 采用冒泡法编写51单片机排序程序
- 冬令营成都集训总结
- 单片机播放音乐的基本知识
- Java的数据类型
- 51单片机演奏乐曲的程序