Add a background selection that references the image or selector (for example, below), and make the button transparent:
<RadioButton android:id="@+id/radio0" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/yourbuttonbackground" android:button="@android:color/transparent" android:checked="true" android:text="RadioButton1" />
If you want your switches to have a different resource when it's set, create a selector background selection:
Res / draw / yourbuttonbackground.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:drawable="@drawable/b" android:state_checked="true" android:state_pressed="true" /> <item android:drawable="@drawable/a" android:state_pressed="true" /> <item android:drawable="@drawable/a" android:state_checked="true" /> <item android:drawable="@drawable/b" /> </selector>
In the selector above, we refer to two drawings, a and b , here, how we create them:
res / drawable / a.xml - Selected state
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="5dp" /> <solid android:color="#fff" /> <stroke android:width="2dp" android:color="#53aade" /> </shape>
res / drawable / b.xml - Regular state
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <corners android:radius="5dp" /> <solid android:color="#fff" /> <stroke android:width="2dp" android:color="#555555" /> </shape>
Read more about drawables here: http://developer.android.com/guide/topics/resources/drawable-resource.html
Evan Bashir 03 Oct '13 at 16:08 2013-10-03 16:08
source share