I am working on an Android app where I have a radiogroup with 3 radio button.
The following is the code for the same:
<RadioGroup android:id="@+id/radioButtonGroup" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" >
<RadioButton android:id="@+id/oneRadioButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:button = "@null"
android:text="@string/one_text"
android:gravity="center" >
</RadioButton>
<RadioButton android:id="@+id/twoRadioButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/two_text"
android:button = "@null" android:gravity="center">
</RadioButton>
<RadioButton android:id="@+id/threeRadioButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="@string/three_text"
android:button = "@null" android:gravity="center" >
</RadioButton>
</RadioGroup>
From the code you can see that I have set android:button = “@null”. I have done this just because I don’t want the button and I just want the text.
My problem is that even when I have set button to null I am able to see a gap on left side text for each radio button, like this
| (gap)rbt1(gap)rbt2(gap)rbt3 |
| |
How do I remove this gap? I tried android:layout_marginLeft="-20dp" which made the text closer but this also made the button overlap each other.
Try to use
android:background="@android:color/transparent"for radiobutton in xml file like this withandroid:button = "@null"also