(1)在drawable文件夹下建立xml文件,文件名自定义
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/weixuanzhong2" android:state_checked="true"/> //选中后的选项,其余两个为未选中和默认的
<item android:drawable="@drawable/weixuanzhong" android:state_checked="false"/>
<item android:drawable="@drawable/weixuanzhong"/>
</selector>
(2)在style文件里面加入如下:
<style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
<item name="android:button">@drawable/checkbox_style</item>
</style>
(3)在布局文件引用即可:
style="@style/CustomCheckboxTheme"