<?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.
<style name="MyCheckBox" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox</item>
应用到checkbox:
<CheckBox android:layout_width="wrap_content"
android:layout_height="wrap_content" style="@style/MyCheckBox"/>


更多相关文章

  1. Android(安卓)ProgressBar的使用
  2. Android(安卓)RelativeLayout用到的一些重要的属性
  3. ProgressBar的样式及用法
  4. wifi和GPRS下获取android的IP信息
  5. 安卓布局
  6. Android(安卓)Activity onConfigurationChanged()方法 监听状态
  7. [长姿势了]android:padding和android:margin的区别
  8. textview中有很多行,我只让它显示三行,最后显示...,我设置了androi
  9. android:layout_gravity和android:gravity属性的区别

随机推荐

  1. android + PHP 实现消息推送(采用MQTT协议
  2. 如何调用android通讯录?
  3. duplicate entry: android/support/v4/in
  4. android 加载进度条动画
  5. android alarm相关信息
  6. Android(安卓)时间戳和时间之间的转化
  7. android segment fault logcat相关信息分
  8. [Android(安卓)UI界面] 怎样实现ListView
  9. Android存储设备管理
  10. android实现虚拟按键实例