https://kotlinlang.org logo
#android
Title
# android
l

luke_c

06/30/2020, 1:48 PM
Is this correct behaviour for a RadioButton? It’s not centred within its view boundaries, so when we add a TextView next to it there’s too much space
Inspected all its attributes in the layout inspector and can’t see where it’s coming from
h

hallvard

06/30/2020, 2:21 PM
Use the Force, Luke!
(Sorry, not very helpful, I know ... I just couldn't resist)
p

Paul Woitaschek

06/30/2020, 5:14 PM
Set the dimensions to wrap content
v

Vova Buberenko

07/01/2020, 11:36 AM
It is normal for default RadioButton with no text set to it. Unfortunately, even if you set empty text to it it won’t change its size to become centered. If you want to have a centered RadioButton I would suggest such hack (just set the size you need for your app):
Copy code
<RadioButton
    android:id="@+id/radioButton"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:background="?android:attr/listChoiceIndicatorSingle"
    android:button="@null" />
It will produce centered RadioButton
p

Paul Woitaschek

07/01/2020, 11:46 AM
Or remove the min size