Search code examples
androidlocaleright-to-left

android Locale.Builder() doesn't mirror the page in right-to-left locales


When I use

locale = new Locale("ar"); 

the screen is mirrored in the right way.

In order to give the option to set the numeric system, i have to use the Locale.Builder() inserted with lollipop.

locale = new Locale.Builder().setLanguage("ar").setRegion("MA").setExtension(Locale.UNICODE_LOCALE_EXTENSION, "nu-latn").build();

The problem is that in this way the screen is not mirrored properly. There is a way, like an Extension, to set the rtl attribute?


Solution

  • SOLUTION: In order to mirror the screen properly, you have to use the Configuration.

    Configuration config = new Configuration();
    config.locale = locale;
    config.setLayoutDirection(new Locale("ar"));