How to position the shortcut from right to left instead of left to right according to the selected language?

I have a multilingual application. which is great for the app, is in English, and all the shortcuts are located perfectly in the required places.

Now I have a script, when I change the language from English to Arabic, the application correctly translates. But the problem is label placement, I want to put labels from rtl instead of ltr.

+4
source share
3 answers

For API level 17 or higher Set the property textDirectionin XML

android:textDirection="anyRtl"

For lower level API 17, use the property textAlignmentin XML

android:textAlignment="viewStart"
+3
source

@Ankita textDirection:"anyRtl", , - " " " ",

"any-RTL". - RTL, RTL, LTR, - LTR. , .

2 . , , textDirection="rtl"

, Ankita , , anyRTL.

, .

. , , , ,

To the right of the layout, left or left to right

+1

To support RTL in your application, you first need to add android:supportsRtl="true"to the element <application>in the manifest file.

If application API ≥ 17, replace all

layout_marginLeft with layout_marginStart

layout_marginRight with layout_marginEnd

paddingLeft with paddingStart

paddingRight with paddingEnd

and if your application supports API <17 add layout_marginStart, layout_marginEndalong with layout_marginLeft,layout_marginRight

0
source

Source: https://habr.com/ru/post/1695505/


All Articles