第一步:在drable下面创建checkbox.xml文件 <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!--<item android:drawable="@drawable/btn_purple_select" android:state_focused="true" />--> <item android:drawable="@drawable/icon_checkbox_select" android:state_pressed="true" /> <item android:drawable="@drawable/icon_checkbox_select" android:state_checked="true" /> <item android:drawable="@drawable/icon_checkbox" /> </selector>
第二步:在style文件夹下面引用checkout文件
<resources> <style name="CustomCheckBoxTheme" parent="@android:style/Widget.CompoundButton.CheckBox"> <item name="android:button">@drawable/checkbox</item> </style> </resources>
第三步:布局里面引用style文件
<CheckBox android:id="@+id/cb_cabin_door_two" android:layout_width="wrap_content" android:layout_height="wrap_content" android:checked="false" android:text="2号舱无货" android:textColor="@color/white" android:textSize="45px" style="@style/CustomCheckBoxTheme"/>