Radiogroup
<Radiogroup Android:id="@+id/client_charge_radiogroup"Android:layout_width="200DP"Android:layout_height="40DP"Android:layout_marginleft="5DP"Android:layout_alignparentright="true"Android:fadingedge="None"android:gravity="center_vertical"android:layout_centervertical="true"android:orientation="Horizontal"> <RadioButton Android:id="@+id/client_radio_label"Android:layout_width="0DP"Android:layout_height="match_parent"Android:layout_weight="1"Android:button="@color/transparent"android:gravity="Center"Android:text="Client"Android:textcolor="@color/color_radiobutton"Android:background="@drawable/radio_group_selector"/> <RadioButton Android:id="@+id/firm_radio_label"Android:layout_width="0DP"Android:layout_height="match_parent"Android:layout_weight="1"Android:button="@color/transparent"android:gravity="Center"Android:text="Firm"android:checked="true"Android:textcolor="@color/color_radiobutton"Android:background="@drawable/radio_group_selector"/> </RadioGroup>
RadioButton Font Color Change Color_radiobutton.xml
<?xml version="1.0"encoding="Utf-8"? ><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true"Android:color="@color/color_text_selected"/> <!--not selected-<item android:state_checked="false"Android:color="@color/color_text_normal"/> </selector>
RadioButton Background color Change Radio_group_selector.xml
<?xml version="1.0"encoding="Utf-8"? ><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_checked="true"android:drawable="@color/color_bg_selected"></item> <item android:state_checked="false"android:drawable="@color/color_bg_normal"></item></selector>
Color.xml
<color name="transparent">#000000</color> <color name= " color_bg_selected "> #e0301e </color> <color name="color_bg_normal"># e7e7e8</color> <color name="color_text_selected"> #ffffff </ color> <color name="color_text_normal">#000000</ Color>
Activity
Clientradiogroup = (radiogroup) Findviewbyid (r.id.client_charge_radiogroup); Clientradiogroup.setoncheckedchangelistener (new Oncheckedchangelistener () { @Override publicvoidint checkedid) { int Radiobuttonid = Group.getcheckedradiobuttonid (); = (RadioButton) Findviewbyid (Radiobuttonid); = Rb.gettext (). toString (); } );
RadioButton selection of Android radiogroup change font color and background color