Android: gravity = "start" in RTL aligns text left to right

When testing my layout on an RTL device (in Arabic), I found that TextView is gravity: start aligning the text to the left, not the right! I tried android: textAlignment = "viewStart" and it works correctly, but due to API requests I was not dependent on it.

my code (I mean the first text in my code):

<LinearLayout android:orientation="horizontal" android:gravity="center_vertical" > <TextView android:text="Size" android:gravity="start" android:layout_weight="1" android:layout_width="0dp" android:layout_height="wrap_content"/> <LinearLayout android:gravity="center" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="000" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="subtext"/> </LinearLayout></LinearLayout> 
+5
source share
2 answers

For full support or RTL you need to configure api 17

If you are targeting your application on Android 4.2 (the targetSdkVersion or minSdkVersion application is 17 or higher), then you should use "start" and "end" instead of "left" and "right". for instance

Native RTL support in Android 4.2

+3
source

My current workaround for this, if someone is interested in the future, is adding an empty view between the two elements and making it fill the empty space between them (weight = 1) so that they align correctly. However, I do not understand that the abnormal behavior of gravity = "start"

+1
source

All Articles