I want to create a radio button that looks like this:
That is, when selected, a checkmark shows up to indicate it is selected instead of a dot. When unselected, there is only an orange background (or some other color).
The black background of the page is just the background of the app.
I know that I could create different drawables for different state for each button, but this is not really extensible if there are a lot of colors.
I was thinking that I could add a checkmark image as a drawable for the android:button
attribute and supply different colors for android:background
for the radio buttons. But it doesn't work well because the shape of the background is always square. So I ended up having a square button.
What is the best way to implement such a button? Or, how do I change the background shape to be round/oval instead of square?
This is what I have right now:
<!-- layout.xml -->
<RadioButton
android:id="@+id/radio1"
android:layout_width="40dp"
android:layout_height="40dp"
android:background="@color/orange"
android:button="@drawable/radio"/>
<!-- drawable/radio.xml -->
<item
android:state_checked="true"
android:drawable="@drawable/checkmark_on_oval"
>
</item>