2015-04-21 69 views
0

我已將radiobuttondrawble設置爲使其顯示在文本的右側。 但我想爲此單選按鈕設置Holo樣式。怎麼樣 ?如何爲android單選按鈕設置Holo樣式

代碼:

<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" /> 
+0

在單選按鈕中設置Holo背景圖像。 – Destro

回答

1

使用?android:attr/listChoiceIndicatorSingle出任右抽拉同時禁用默認單選按鈕的外觀(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

代碼:

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