Search code examples
androidandroid-radiobutton

Android Radio Button left padding to 0


Need help with radio button

My 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>

There is this space on the left between the circle and the left side of the linear layout. How do I get rid of that space? In TextViews setting minWidth to 0dp does the trick but I could not do it for RadioButtons. ANy ideas


Solution

  • there are few ways to do it, you can try this

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

    ... android:layout_marginLeft="-10dp"

    does it do what you need ?