Android 上带有边距的 RadioButton 左侧的文本 [英] Text leftside of a RadioButton with a margin on Android
问题描述
我想要标签", - 您在 RadioButton
中设置的文本以显示按钮的左侧并在两者之间有一些填充.
I want to have the "label", - the text you set in your RadioButton
to show left of the button and have some padding in between.
在布局中添加额外的 TextView
不起作用,因为我的 RadioGroup
不起作用(我可以选择多个按钮)如果我添加除 RadioButton
进入 RadioGroup
.
Adding an additional TextView
into the layout doesn't work because my RadioGroup
does not work (i can choose multiple buttons) if i add anything other then a RadioButton
into the RadioGroup
.
那么,我怎样才能将 RadioButton 更改为 <text><buttondrawable>
而不是 <buttondrawable><text>
So, how can i change the RadioButton to be <text><buttondrawable>
instead of <buttondrawable><text>
推荐答案
可以通过设置android:button="@null"
并添加RadioButton的drawable
来实现代码> 为 android:drawableRight
.您可以使用 android:drawablePadding
更改文本和可绘制对象之间的填充.
You can achieve this by setting android:button="@null"
and adding the drawable of the RadioButton
as android:drawableRight
. You can change the Padding between the text and the drawable with android:drawablePadding
.
<RadioGroup
android:id="@+id/radios"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:inputType="text"
android:orientation="vertical" >
<RadioButton
android:id="@+id/first"
android:button="@null"
android:drawableRight="@android:drawable/btn_radio"
android:drawablePadding="20dp"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:text="@string/first"
android:textSize="20dip" />
<RadioButton
android:id="@+id/second"
android:button="@null"
android:drawableRight="@android:drawable/btn_radio"
android:drawablePadding="20dp"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:text="@string/second"
android:textSize="20dip" />
</RadioGroup>
</RelativeLayout>
这篇关于Android 上带有边距的 RadioButton 左侧的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!