Android RadioButton 选中改变颜色
Android About 1,208 words方法
新建文件,写在color
文件夹下,不是 values 的 colors.xml,给RadioButton
的textColor
设置"@color/xxx"
。
radiobutton
字体颜色改变color_radiobutton.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@color/color_text_selected"/>
<!-- not selected -->
<item android:state_checked="false" android:color="@color/color_text_normal"/>
</selector>
radiobutton
背景颜色改变radio_group_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_checked="true" android:drawable="@color/color_bg_selected"/>
<item android:state_checked="false" android:drawable="@color/color_bg_normal"/>
</selector>
color.xml
(as
的values
的是colors.xml
文件)
<color name="transparent">#000000</color>
<color name="color_bg_selected">#e0301e</color>
<color name="color_bg_normal">#e7e7e8</color>
<color name="color_text_selected">#ffffff</color>
<color name="color_text_normal">#000000</color>
Views: 7,316 · Posted: 2019-04-11
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...