我試圖改變RadioButton上的選中按鈕的drawable,但沒有任何顯示;設置drawable只是刪除已經存在的默認值。RadioButton'android:button'什麼也不做
我使用堆棧溢出來嘗試找到解決方案,但是當我嘗試實現它時,沒有可繪製的顯示。我的選擇器似乎很好,因爲當我設置顯示我的圓圈的單選按鈕的background
。
我敢肯定,這是一個非常明顯的問題,我會因爲看不見而自拍;誰能弄清楚什麼是錯的?
我的單選按鈕
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:id="@+id/radio0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Left"
android:checked="false"
android:button="@drawable/radio_button" />
<RadioButton
android:id="@+id/radio1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/radio_button"
android:text="Right"
android:checked="true" />
</RadioGroup>
隨着我的選擇
沒有我的選擇
我選擇XML
<?xml version="1.0" encoding="UTF-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:drawable="@drawable/radio_button_checked"
android:state_checked="true" />
<item
android:drawable="@drawable/radio_button_unchecked" />
</selector>
radio_button_checked.xml
<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/primary_button_color"/>
<stroke
android:width="2px"
android:color="#000000"/>
</shape>
radio_button_unchecked.xml
<?xml version="1.0" encoding="UTF-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
android:width="2px"
android:color="#000000"/>
</shape>
修好了,謝謝!現在看起來很明顯! – RobVoisey