- 选中时候效果
- 取消选中效果
1.先在drawable目录下定义一个样式文件
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/login_auto_check_true" android:state_checked="true"/>
<item android:drawable="@drawable/login_auto_check_false" android:state_checked="false"/>
</selector>
其中login_auto_check_true、login_auto_check_false 为选中和没选中的图片。
2.定义好了样式文件后直接在CheckBox控件中引用就行了
<CheckBox
android:id="@+id/cb_auto_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/login_auto_check"
android:checked="true" />