在资源文件夹drawable中新建一个checkbox.xml文件
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/check_box" android:state_checked="true" />
<item android:drawable="@drawable/check_box_b" android:state_checked="false" />
</selector>
在里面设置一张选中后的图片和一张选中前的图片。
<CheckBox
android:id="@+id/cb_child"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:button="@drawable/checkbox"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
然后在CheckBox里设置button
android:button="@drawable/checkbox"
当然其他属性也不能少,这样就完成,想要什么样式就用什么样式的图片