图像(编者):
我有两个用于单选按钮的drawable。一个用于正常状态,另一个用于检查状态。当我将它设置为单选按钮的按钮属性时,它是不可见的。请告诉我这里我做错了什么。
radio_pressed:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="ring"
android:useLevel="false"
android:thickness="1dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<solid
android:color="#ffffff">
</solid>
<size
android:height="10dp"
android:width="10dp">
</size>
</shape>
</item>
<item
android:top="3dp"
android:bottom="3dp"
android:right="3dp"
android:left="3dp">
<shape android:shape="oval"
android:useLevel="false"
>
<solid
android:color="#ffffff">
</solid>
</shape>
</item>
</layer-list>
radio_normal:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:useLevel="false"
android:thickness="10dp">
<solid
android:color="#2196f3">
</solid>
</shape>
radio_bg:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="true"
android:drawable="@drawable/radio_pressed"
>
</item>
<item
android:state_checked="false"
android:drawable="@drawable/radio_normal"
>
</item>
</selector>
activity_main.xml中:
<RadioButton
android:id="@+id/radio"
android:layout_centerInParent="true"
android:layout_width="40dp"
android:button="@drawable/radio_bg"
android:layout_marginTop="100dp"
android:layout_height="40dp"
/>