我想使用简单的形状状态选择器更改 RadioButton 的指示器。我创建了以下名为 Moon_radio.xml 的 XML,并将其放置到 drawable
文件夹中。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:state_pressed="false">
<shape
android:shape="oval">
<solid android:color="@color/moon_light_plate" />
</shape>
</item>
<item android:state_checked="false" android:state_pressed="false">
<shape
android:shape="oval">
<stroke
android:width="2dp"
android:color="@color/moon_light_plate" />
</shape>
</item>
<item android:state_checked="true" android:state_pressed="true">
<shape
android:shape="oval">
<solid android:color="@color/moon_light_plate_pressed" />
</shape>
</item>
<item android:state_checked="false" android:state_pressed="true">
<shape
android:shape="oval">
<stroke
android:width="2dp"
android:color="@color/moon_light_plate_pressed" />
</shape>
</item>
</selector>
然后我在布局中的 RadioButton 上指定 android:button="@drawable/moon_radio"
属性。由于某种原因,这不起作用。怎么了?
* 编辑* 可能我解释不清楚,但是我不想更改背景,我想更改指示器,即默认点。
这就是我得到的:
这就是我想要得到的”
最佳答案
您应该在 RadioButton
的 android:button
属性中指定它是正确的,您只需要添加 android:background="@android:color/transparent"
关于java - 使用 XML 可绘制的 RadioButton 样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20756115/