Android单选按钮左侧填充为0

时间:2014-06-12 17:35:01

标签: android android-radiobutton

需要有关单选按钮的帮助

我的xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="0dp"
            android:minWidth="0dp"
            android:text="Hello" />

        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="0dp"
            android:text="World" />
    </RadioGroup>

</LinearLayout>

在线性布局的圆圈和左侧之间的左侧有这个空间。我如何摆脱那个空间?在TextViews中,将minWidth设置为0dp就可以了,但我无法为RadioButtons做到这一点。任何想法

2 个答案:

答案 0 :(得分:3)

有几种方法可以做到,你可以试试这个

<RadioGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginLeft="-10dp" 
    >

...     机器人:layout_marginLeft =&#34; -10dp&#34;

它能做你需要的吗?

答案 1 :(得分:0)

我认为你想要的是这样的

        <RadioButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="-5dp"
        android:text="Hello" />

你不需要

        android:layout_marginStart="0dp"
        android:minWidth="0dp"

你可以玩

android:layout_margin

直到你得到你想要的东西。

您可以获得有关保证金属性here

的更多信息

我希望这可以帮到你!