Android RadioButton RTL Layout not applying padding

Viewed 51

I am trying to use RTL in my layout.

        <androidx.appcompat.widget.AppCompatRadioButton
            android:id="@+id/radioButton"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/transparent"
            android:button="@drawable/radio_button"
            android:foreground="?android:attr/selectableItemBackground"
            android:padding="18dp"
            android:text="String"
            android:textColor="color"
            android:textSize="14sp" />

LTR Layout:

enter image description here

RTL Layout:

enter image description here

In the RTL Layout the right padding is not being applied to the radio button and the text goes to the left side. Is there any option to fix this.

1 Answers

To have the text near radio button, you can put the text alignment to start of the view. android:textAlignment="viewStart"

To have the radio button respect margins, you can use drawableStart

<androidx.appcompat.widget.AppCompatRadioButton
        android:id="@+id/radioButton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/transparent"
        android:foreground="?android:attr/selectableItemBackground"


         android:button="@null"
         android:drawableStart="@drawable/radio_button"
         android:drawablePadding="11dp"
         android:padding="18dp"
         android:textAlignment="viewStart"


        android:text="Radio Button Text"
        android:textColor="#000000"
        android:textSize="14sp"
        />
Related