2

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?

Blodhgard
  • 9,130
  • 3
  • 24
  • 36

1 Answers1

2

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"));
Blodhgard
  • 9,130
  • 3
  • 24
  • 36
  • with this config you create a new Resources and then you use these resources for getting the strings? – kingston Dec 15 '15 at 13:43
  • How do you force the context to use this new config? context.getApplicationContext().getResources().updateConfiguration(config, context.getApplicationContext().getResources().getDisplayMetrics()); – kingston Dec 15 '15 at 13:49
  • Another problem with the solution above is that after setting the extension the country is ignored so if you have en_gb and en_ie, en_gb is used for Ireland too – kingston Jan 04 '16 at 10:34
  • http://stackoverflow.com/questions/34266789/arabic-number-in-arabic-text-in-android – kingston Jan 11 '16 at 14:01