在 Android 上带有边距的 RadioButton 左侧的文本 [英] Text leftside of a RadioButton with a margin on Android

查看:28
本文介绍了在 Android 上带有边距的 RadioButton 左侧的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要标签" - 您在 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 更改为 而不是

So, how can i change the RadioButton to be <text><buttondrawable> instead of <buttondrawable><text>

推荐答案

你可以通过设置 android:button="@null" 并添加 RadioButton 的 drawable 来实现code> 为 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆