1. android:button="@null" 可以屏蔽CheckBox的选择框
2.android:textColor="@drawable/selector_text_color" 文本text 设置selectColor
效果图:
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="@dimen/dp_36" android:layout_marginRight="@dimen/dp_36" android:orientation="vertical"> <CheckBox android:id="@+id/course_checkbox" android:layout_width="match_parent" android:layout_height="@dimen/edit_box_height" android:layout_marginTop="@dimen/dp_10" android:gravity="center" android:button="@null" android:background="@drawable/selector_btn_checkbox" android:textColor="@drawable/selector_text_color" android:textSize="@dimen/sp_18" android:text="课程类" /> <CheckBox android:id="@+id/article_checkbox" android:layout_width="match_parent" android:layout_height="@dimen/edit_box_height" android:layout_marginTop="@dimen/dp_10" android:gravity="center" android:button="@null" android:background="@drawable/selector_btn_checkbox" android:textColor="@drawable/selector_text_color" android:textSize="@dimen/sp_18" android:text="文章类" /> </LinearLayout>
drawable/selector_text_color.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="@color/colorAccent" android:state_checked="true"/> <item android:color="#ff979797" android:state_checked="false" /> </selector>
同样适用于RadioButton