1、创建on_blace_off_white_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:color="@color/black" android:drawable="@color/black"/>
<!-- pressed -->
<item android:state_focused="true" android:color="@color/black" android:drawable="@color/black"/>
<!-- focused -->
<item android:state_checked="true" android:color="@color/black" android:drawable="@color/black"/>
<!-- checked -->
<item android:color="@color/black" android:drawable="@color/white"/>
<!-- default 此为默认的,一定要有-->
</selector>
NOTE:其为一个selector,drawable如果不设置,编译可能无法通过,如果要此selector要被设置为textColor,那么color选项一定要有
2、在对应的按钮中设置textColor为@drawable/on_blace_off_white_selector,如下:
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/home_page_tab_style"
android:textColor="@drawable/on_black_off_white_selector"
android:text="haha"
/>