How to make a RadioButon without text?
Asked Answered
K

1

11

I just want a simple RadioBttun without text and I did the code below but what I get is a radiobutton widget with little space that is I think reserved to the text. So How should get rid of this space ?

<RadioButton
    android:id="@+id/rb_topup_item_account_selection_status"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@null" />

enter image description here

Kilar answered 9/9, 2020 at 9:15 Comment(11)
Have you tried removing this line android:text="@null" altogether ?Catacomb
@Catacomb yes I did and I got the same result. Also I tried android:text="" but the sameKilar
Please post the layout in which you are using this button.Catacomb
@Catacomb sorry but no need and when I try to put the code the stackEditor insist and tell me that there is code more than what is explaned. It just a LinearLayout with three widgets: an icon, textview and a radiobuttonKilar
If I add a RadioButton to any layout and I don't include the android:text attribute, I get your desired result.Lattimore
@NikosHidalgo It is strange I tried it but I got the same resultKilar
Maybe it has something to do with the app theme or styling in general. Do you get the same in different devices/emulators?Lattimore
@NikosHidalgo there is no such a thing and yes I get the same resultKilar
I also get the "Desired" output when I didn't add the text attribute: ResultPronounce
Shared your full layout XML code, it is working fine without text nullIntersection
Have you figure it out? I have the same issue when I add padding to radio buttonAblebodied
P
25

Just add the below attributes to the RadioButton element in your XML layout. It will remove the default padding.

android:minWidth="0dp"
android:minHeight="0dp"
Pareira answered 28/7, 2021 at 13:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.