Reputation: 975
While testing my layout on a device with RTL language (Arabic) I found that TextView with gravity:start keeps aligning the text to the left instead of right ! I tried android:textAlignment="viewStart" and it works correctly but due to API reqs I didn't depend on it.
my code (I mean the first textview 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>
Upvotes: 9
Views: 4972
Reputation: 975
My current workaround for this if any one 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 they get aligned properly. Still I don't understand that abnormal behavior of gravity="start"
Upvotes: 1
Reputation: 27535
For Full support or RTL you have to target api 17
If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”. For example
Upvotes: 3