Android User-Defined radiobutton style to achieve what you want, androidradiobutton
:
The style customization for radiobutton is nothing more than the style. There is a background in the style to set the radiobutton background button to set the radiobutton small box. When it is null, it is not a box.
The first custom style:
<style name="CustomRadioBtn"> <item name="android:button">@drawable/mycustome_radio_selctor</item> </style>
Code for mycustome_radio_selctor xml:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/enable_on_pressed" android:state_checked="true" android:state_enabled="true" android:state_pressed="true"/> <item android:drawable="@drawable/enable_off_pressed" android:state_checked="false" android:state_enabled="true" android:state_pressed="true"/> <item android:drawable="@drawable/enable_on" android:state_checked="true" android:state_enabled="true"/> <item android:drawable="@drawable/enable_off" android:state_checked="false" android:state_enabled="true"/> <item android:drawable="@drawable/disabled_on" android:state_checked="true" android:state_enabled="false"/> <item android:drawable="@drawable/disabled_off" android:state_checked="false" android:state_enabled="false"/></selector>
The second custom style:
<style name="CustomRadioBtn2"> <item name="android:gravity">center</item> <item name="android:background">@drawable/rb_nobtn_selector</item> <item name="android:button">@null</item> </style>
Rb_nobtn_selector xml:
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/rb_pressed_bg" android:state_checked="true"></item> <item android:drawable="@drawable/rb_normal_bg" android:state_checked="false"></item></selector>
You only need to pay attention to the state_checked status.
In this way, the effect is achieved. It is better to use the. 9 image, and set the gravity to center.
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.