1.首先在drawable文件夹中添加drawable文件checkbox_style.xml。


[html]view plaincopy

  1. <?xmlversion="1.0"encoding="utf-8"?>

  2. <selectorxmlns:android="http://schemas.android.com/apk/res/android">

  3. <itemandroid:drawable="@drawable/checkbox_pressed"android:state_checked="true"/>

  4. <itemandroid:drawable="@drawable/checkbox_normal"android:state_checked="false"/>

  5. <itemandroid:drawable="@drawable/checkbox_normal"/>

  6. </selector>

2.在values文件夹下的styles.xml文件中添加CustomCheckboxTheme样式。



[html]view plaincopy

  1. <stylename="CustomCheckboxTheme"parent="@android:style/Widget.CompoundButton.CheckBox">

  2. <itemname="android:button">@drawable/checkbox_style</item>

  3. </style>

3.在布局文件中使用CustomCheckboxTheme样式。



[html]view plaincopy

  1. <CheckBox

  2. android:id="@+id/select_all"

  3. android:layout_width="wrap_content"

  4. android:layout_height="wrap_content"

  5. style="@style/CustomCheckboxTheme"/>


使用到的图片资源

checkbox_normal.png

checkbox_pressed.png

转载自:http://blog.csdn.net/zuolongsnail/article/details/7106586

更多相关文章

  1. Android开发入门之拨打电话
  2. Android(安卓)Studio 在命令行编译工程
  3. aar文件的libs有其他jar文件,使用时的注意点
  4. java更改android文件权限--待验证
  5. 2011-03-29 15:30 android用于打开各种文件的intent【原创】

随机推荐

  1. 安卓表格布局android:collapseColumns,an
  2. Android测试教程(2):测试基础
  3. android gesture检测
  4. Phonegap软键盘遮挡输入框问题
  5. 漫谈Android安全框架
  6. Android开发者指南(11) ―― Optimizing
  7. Android NDK环境搭建
  8. Android(安卓)Lifecycle 生命周期管理
  9. HelloWorld-----Google手机操作系统Andro
  10. android客户端与服务端交互的三种方式