Issue
I've tried to change the drawable of the checked button on a RadioButton but nothing is showing; setting the drawable just removes the default one that is already there.
I used stack overflow to try find a solution but when I try to implement it, there is not drawable showing up. My selector appears to be fine because when I set the background
of the radio button that displays my circles.
I'm sure it's a very obvious problem which I'll slap myself for not seeing; can anyone figure out what is wrong?
My Radio Buttons
<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>
With my selector
Without my selector
My Selector 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>
Solution
I think you can't see anything because your drawable don't have any size.
Try to define <size android:width="60dp" android:height="60dp"/>
under the shape of your xml.
Answered By - Eselfar
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.