Ever since I upgraded to android oreo on a mobile phone, my RTL support for the application does not work. it changes the lines to Arabic, but does not change the direction of the layout. but if I run the same RTL transition to any device lower than oreo, everything works fine. Has anyone else experienced this problem? Is there any official expression about this error and workaround?
Below is my method of changing the locale
public static boolean setDefaultLocale(Context context) { Resources resources = context.getResources(); PreferenceManager preferenceManager = PreferenceManager.getInstance(); String localLanguage = resources.getConfiguration().locale.getLanguage(); boolean isLanguageChanged = !preferenceManager.getCurrentLanguageCode().equalsIgnoreCase(localLanguage); if (isLanguageChanged) { Log.d("", preferenceManager.getCurrentLanguageCode()); Locale locale = new Locale(preferenceManager.getCurrentLanguageCode()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) Locale.setDefault(Locale.Category.DISPLAY, locale); else Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; resources.updateConfiguration(config, resources.getDisplayMetrics()); ((Activity) context).recreate(); } return isLanguageChanged; }
source share