5

I think the source of the problem is that my phone language is right-to-left. So in Android Studio preview, when i try to use horizontal LinearLayout it shows the views im adding from left to right, but running on my phone it switches the order from right to left. How can i force Linear Layout views to add from left to right?

gga
  • 107
  • 7

2 Answers2

3

Try to play with android:layoutDirection parameter in your XML layout file to explicitly define the direction of your Views

EDIT

This feature is available from API 17, so you'll need to implement it differently in earlier versions.

Yury Fedorov
  • 14,508
  • 6
  • 50
  • 66
1

I would like to add that according to developer.android it's only available in API 17 and higher:

Note: To enable right-to-left layout features for your app, you must set supportsRtl to "true" and set targetSdkVersion to 17 or higher.

reference:Layout direction

for lower API (which still relevant today) it's a lit bit messy, some of issues (and solutions) discussed here: layoutDirection android pre 4.2

Nikita Kurtin
  • 5,889
  • 4
  • 44
  • 48
  • Thanks Nikita, i need help with how can i force the action bar to be "left-to-right" using a menu.xml? i created a menu.xml file with 2 items in it, but the app name is at the right end and the 2 items are in this "three dots" icon. how can i control the action bar layout direction? – gga Dec 28 '15 at 10:51
  • 1
    ok thanks i fixed it. just changed - android:supportsRtl="true" to android:supportsRtl="false" in AndroidManfiest.xml under " – gga Dec 28 '15 at 11:10