jul
jul

Reputation: 37464

Issue when centering two-lines text in a RadioButton

I've got a RadioGroup with several RadioButtons in it. When the text in the RadioButton has two lines I get an unwanted top margin for my RadioButton.

Anybody could help?

UPDATE

I tried to set the padding of the RadioButtons to 0, I also tried with LinearLayout and Buttons. Nothing works...

enter image description here enter image description here

<RadioGroup
    android:id="@+id/filter_bar"
    android:layout_width="400dp"
    android:layout_height="40dp"
    android:background="@drawable/bg_filter"
    android:checkedButton="@+id/btn_filter_1"
    android:orientation="horizontal">

    <RadioButton
        android:id="@+id/btn_filter_1"
        android:layout_width="80dp"
        android:layout_height="40dp"
        android:background="@drawable/btn_filter"
        android:button="@null"
        android:gravity="center"
        android:text="@string/filter_1"
        android:textColor="#ffffff"
        android:textSize="13sp" />

    <RadioButton
        android:id="@+id/btn_filter_2"
        android:layout_width="80dp"
        android:layout_height="40dp"
        android:background="@drawable/btn_filter"
        android:button="@null"
        android:gravity="center"
        android:text="@string/filter_2"
        android:textColor="#ffffff"
        android:textSize="13sp" />

    <!-- 3 more RadioButtons -->

</RadioGroup>

Upvotes: 2

Views: 1073

Answers (1)

R&#233;mi F
R&#233;mi F

Reputation: 1335

As it is said in the documentation SetGravity is specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. This is not the case here.

Upvotes: 1

Related Questions