How to set Holo style for android radiobutton

613 Views Asked by At

I have set the radiobutton drawble to make it appears to the right of the text. But I want to set the Holo style for this radiobutton. how ?

code:

<RadioButton
   android:id="@+id/rb2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:button="@null"
   android:drawableRight="@android:drawable/btn_radio"
   android:paddingLeft="40dip"
   android:tag="2"
   android:text="@string/Conflict_of_intrest" />
2

There are 2 best solutions below

0
Rowan On

Use ?android:attr/listChoiceIndicatorSingle as right-drawable while disabling default radio button look(android:button="@null")

<style name="rtlRadioBtn" parent="android:Widget.Holo.Light.CompoundButton.RadioButton">
     <item name="android:button">@null</item>
     <item name="android:drawableRight">?android:attr/listChoiceIndicatorSingle</item>
     <item name="android:gravity">right|center_vertical</item>
</style>
0
wiz On

Code:

Drawable radio;

try {
    TypedValue typedValue = new TypedValue();
    Theme theme = getContext().getTheme();
    theme.resolveAttribute(android.R.attr.listChoiceIndicatorSingle, typedValue, true);
    radio = getContext().getResources().getDrawable(typedValue.resourceId);
} catch (Exception e) {
    radio = getContext().getResources().getDrawable(android.R.drawable.btn_radio);
}

XML:

?android:attr/listChoiceIndicatorSingle