首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android checkbox自定义式样

2012-06-30 
android checkbox自定义样式1. 首先要导入你准备用作CheckBox选中和补选中状态的两图片到res的drawable中,

android checkbox自定义样式

1. 首先要导入你准备用作CheckBox选中和补选中状态的两图片到res的drawable中,如checkbox_checked.png,checkbox_normal.png;

2. 在res/drawable中添加checkbox.xml,定义checkbox的state list drawable图片?
view plain

  1. <?xml?version="1.0"?encoding="UTF-8"?>??
  2. ??
  3. ??
  4. <selector?xmlns:android="http://schemas.android.com/apk/res/android">??
  5. ??
  6. ??
  7. ????<item?android:state_checked="true"?android:drawable="@drawable/checkbox_checked"?/>?<!--?checked?-->??
  8. ??
  9. ??
  10. ????<item?android:state_checked="false"?android:drawable="@drawable/checkbox_normal"?/>?<!--?default?-->??
  11. ??
  12. ??
  13. </selector>??

复制view plain
  1. <CheckBox?android:layout_height="wrap_content"?android:id="@+id/chkItem"?android:button="@drawable/checkbox"></CheckBox>??

这样就完成了定制工作,效果如下:
android checkbox自定义式样

热点排行