我已将radiobutton
drawble
设置为显示在文本的右侧。
但我想为这个radiobutton设置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 :(得分: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>
答案 1 :(得分: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