Radio group behaves strangely on my phone and the text is totally misaligned as shown in the image below, but the strange thing is that it's aligned correctly in the XML layout visualizer in android studio
Misaligned Image on my phone
The perfectly fine image on XML layout visualizer in android studio
The XML code of the layout
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mlns="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="@dimen/_28dp_dp"
android:background="@drawable/bg_rounded_screen"
mlns:android="http://schemas.android.com/apk/res/android">
------
<TextView
android:id="@+id/textView"
style="@style/HintTextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_36dp_dp"
android:text="@string/language"
app:layout_constraintBottom_toTopOf="@+id/tg_group_language"
app:layout_constraintStart_toStartOf="@+id/et_name"
app:layout_constraintTop_toBottomOf="@+id/et_phone" />
<RadioGroup
android:id="@+id/tg_group_language"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_30dp_dp"
android:orientation="horizontal"
android:gravity="end"
app:layout_constraintBottom_toTopOf="@+id/btn_save_changes"
app:layout_constraintEnd_toEndOf="@id/et_name"
app:layout_constraintStart_toStartOf="@id/et_name"
app:layout_constraintTop_toBottomOf="@+id/textView"
app:singleSelection="true">
<RadioButton
android:id="@+id/radio_english"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/english" />
<RadioButton
android:id="@+id/radio_arabic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/عربي" />
</RadioGroup>
-----
</androidx.constraintlayout.widget.ConstraintLayout>
NB:
- I didn't apply any styling programmatically
- It seems it works fine when the language of the phone is RTL but when trying to force the language of the app to RTL while the phone is LTR (English) using this answer, it shows this misalignment