1

I am using an android library (leanback library for android tv) and want to set my app layouts independent of the system locale.

In other words, as all of my users use right to left language and layout, I want to prevent rendering layout in "Left to Right" mode even if system language is on a LTR lang like english.

So can I set a flag or do other stuff to make the app ignore system locale totally?


EDIT : Thanks to Andres comment, I followed this link and it works perfectly.

Saleh
  • 1,819
  • 1
  • 17
  • 44

1 Answers1

0

Use android:layoutDirection="rtl" for your layout's root and android:layout_gravity="start" for child views.

This way you force your layout to be right to left and all child views appear on the right side of the parent (start means right in rtl direction).

Armin
  • 2,397
  • 2
  • 21
  • 31
  • 4
    While you can do this, it's usually in bad practice to show english (for example) in rtl since it will be super confusing. If you're forcing a locale, you can just follow this example: https://stackoverflow.com/questions/22402491/android-change-and-set-default-locale-within-the-app and set the locale of the app (before any layout inflation occurs) and your layouts would work as intended. – Andres S Feb 27 '19 at 18:27