Android中自定义checkbox样式
1.首先在drawable文件夹中添加drawable文件checkbox_style.xml。
[html]view plaincopy
<?xmlversion="1.0"encoding="utf-8"?>
<selectorxmlns:android="http://schemas.android.com/apk/res/android">
<itemandroid:drawable="@drawable/checkbox_pressed"android:state_checked="true"/>
<itemandroid:drawable="@drawable/checkbox_normal"android:state_checked="false"/>
<itemandroid:drawable="@drawable/checkbox_normal"/>
</selector>
2.在values文件夹下的styles.xml文件中添加CustomCheckboxTheme样式。
[html]view plaincopy
<stylename="CustomCheckboxTheme"parent="@android:style/Widget.CompoundButton.CheckBox">
<itemname="android:button">@drawable/checkbox_style</item>
</style>
3.在布局文件中使用CustomCheckboxTheme样式。
[html]view plaincopy
<CheckBox
android:id="@+id/select_all"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/CustomCheckboxTheme"/>
使用到的图片资源
checkbox_normal.png
checkbox_pressed.png
转载自:http://blog.csdn.net/zuolongsnail/article/details/7106586
更多相关文章
- Android开发入门之拨打电话
- Android(安卓)Studio 在命令行编译工程
- aar文件的libs有其他jar文件,使用时的注意点
- java更改android文件权限--待验证
- 2011-03-29 15:30 android用于打开各种文件的intent【原创】