I am working on setting the language in my application. I was able to change the locale from my main activity using
Resources resources = getResources(); Configuration configuration = resources.getConfiguration(); DisplayMetrics displayMetrics = resources.getDisplayMetrics(); configuration.setLocale(new Locale("ar")); resources.updateConfiguration(configuration,displayMetrics); recreate();
Everything worked fine, but I noticed that the back button did not change direction to RTL:
This is my expected behavior when I install the language in RTL:
Is it possible?
Try calling this method when installing Arabic:
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void forceRTLIfSupported() { if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){ //HERE CHECK CONDITION FOR YOUR LANGUAGE if it is AR then //change if it is english then don't getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL); } }
, Locale . , Locale (rtl ltr) . Locale Context , Context / (, , ..). , .
Locale
Context
, Locale (, , , ..), SET_CONFIGURATION. docs, SET_CONFIGURATION , . , , , , , adb shell pm grant . , , , .
SET_CONFIGURATION
adb shell pm grant
The direction of the navigation bar (and other parts of the OS, such as Settings) is not related to the application. A user may have an LTR OS with an RTL application. therefore, changing the locale and direction of the application does not affect the underlying OS, and the user must manually change it.
Source: https://habr.com/ru/post/1694387/More articles:Oracle PoolDataSource leaves DB cursor open until commit (), is this the expected behavior? - javaGet index when moving a list with a stream - javaC # - finding a simple way to parse a string value between two different representations (numeric and English) - stringhow to do reverse dictionary lookups - c #Sphere Calculations - c ++Creating an AWS Signature v4 signature to boot onto s3 (migrating from v2) - javaError loading in Xamarin Forms PCL - androidMongoDB: установить значение в коллекции в зависимости от другого объекта - mongodbShould initialized end fields always be static unchanged? - javaI do not serve my images correctly, they are all shown rotated 90 degrees - htmlAll Articles