1.在res/drawable下创建selector 文件 文件名自己随意定义符合格式要求即可
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@mipmap/ic_launcher" android:state_checked="true"/> <item android:drawable="@mipmap/ic_launcher_round" android:state_checked="false"/> </selector>
2.控件中修改CheckBox的button属性
<CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:button="@drawable/check" />