Reputation: 21
Text like "20 minutes before" will be "minutes before 20" in RTL mode.
I feel like the system takes number as Arabic word, thus force 20 to the very right of the text.
<TextView
android:id="@+id/Mytext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="end|right|center_vertical"
android:paddingLeft="4dp"
android:paddingStart="4dp"
android:text="5 minutes before"
android:textDirection="locale"/>
Original string "20 minutes before" is expected.
Upvotes: 2
Views: 1956
Reputation: 618
Please check below code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:id="@+id/Mytext"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingLeft="4dp"
android:paddingStart="4dp"
android:text="20 minutes before"
/>
</LinearLayout>
Upvotes: 0
Reputation: 1829
According to:
https://developer.android.com/guide/topics/manifest/application-element.html#supportsrtl
android:supportsRtl
Declares whether your application is willing to support right-to-left (RTL) layouts. If set to true and targetSdkVersion is set to 17 or higher, various RTL APIs will be activated and used by the system so your app can display RTL layouts. If set to false or if targetSdkVersion is set to 16 or lower, the RTL APIs will be ignored or will have no effect and your app will behave the same regardless of the layout direction associated to the user's Locale choice (your layouts will always be left-to-right).
so, if this is what you want to achieve than simply set android:supportsRtl = false
in Manifest.
Upvotes: 0
Reputation: 69
if you delete "android:textDirection="locale"", then you can see what you want. i don't know which direction you want the "5 minutes before" showing. if left in RTL and LTL mode, you can set " android:gravity="start|center_vertical"", else if right "android:gravity="end|center_vertical"
Upvotes: 2
Reputation: 3404
Try this
<TextView
android:id="@+id/Mytext"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="start"
android:textAlignment="viewStart"
android:paddingLeft="4dp"
android:paddingStart="4dp"
android:text="5 minutes before"/>
Output for LTR
5 minutes before
Output for RTL
before minutes 5
Upvotes: 0