自定义Button样式相同,新建Android XML文件,类型选Drawable,根结点选selector,在这定义具体的样式。 应用到Checkbox:123456789
<?xml version="1.0" encoding="UTF-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true" android:state_pressed="true" android:drawable="@drawable/focused" /> <item android:state_checked="false" android:state_pressed="true" android:drawable="@drawable/normal" /> <item android:state_checked="false" android:drawable="@drawable/normal" /> <item android:state_checked="true" android:drawable="@drawable/focused" /></selector>
state_checked 选中状态 state_pressed按下状态
即分别设置checkbox选中和没选中时,按下和没按下时显示的图片.
应用到Checkbox与Button不同,并不是设置Background属性,而是设置style属性,所以我们要写一个style。
在strings.xml写一个style,123
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox"><item name="android:button">@drawable/checkbox</item></style>
1234
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" style="@style/MyCheckBox" />
详细解决方案
Android 自定义CheckBox 式样
热度:529 发布时间:2016-05-01 17:13:24.0
1 楼 goingshow 2011-10-12
楼主,是否发现 自定义selector 出来的chekbox 占的位置跟以前的一样(长和宽)
相关解决方案
- struts checkbox 页面显示
- checkbox Action传值有关问题
- checkbox 批量剔除 后台接收不到 checkbox的values
- 回答给分,动态创建的input checkbox 该如何取值,即判断是否选中
- checkbox 选中事件解决思路
- jquery checkbox 选中的值为什么是on,该如何解决
- struts1 中<html:checkbox>标签的value值怎么动态赋值
- android 读取byte[]中的元素解决方案
- android 标题栏兑现方式
- android 中Activity向BroadcastReceiver发送数据,该怎么解决
- Android 4.0 为什么模拟器老是提示小弟我谷歌拼音输入法已停止
- android:getSharedPreferences() 这是哪个类的方法解决思路
- android 怎么判断一个程序是否联网
- android 大量数据按周分组,该如何解决
- android RadioButton如何设置默认选中
- ksoap2-android-这个包,连接webService怎么设置超时
- android 怎么重新设置锚点
- android UI界面设计解决方案
- android 图片对象获取的有关问题
- android 怎么调用淘宝支付宝接口
- Android 沿袭InputMethodService自定义输入法
- android 关于服务连接的疑义
- android 两个activity如何通信
- android 怎么实现对view的放大和缩小
- checkbox 多选框有关问题
- android 教程解决方法
- android ID,该如何处理
- 准备复习2-3个月,看java+android,请问有经验者,怎么看效果最好》
- android UI线程与AsyncTask的有关问题
- android(java)中的java.net能不能和c#的system.net.sockets进行tcp通信,该如何解决