Yes, there is issue with Android Oreo for language change(strings and layout direction in arabic,urdu and hebrew), i found the solution this will help you to solve this problem
In LanguageContextWrapper.java class
public static ContextWrapper wrap(Context context, String language) {
Locale locale = new Locale(language);
Locale.setDefault(locale);
Resources resources = context.getResources();
Configuration configuration = resources.getConfiguration();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
configuration.setLocale(locale);
LocaleList localeList = new LocaleList(locale);
LocaleList.setDefault(localeList);
configuration.setLocales(localeList);
configuration.setLayoutDirection(locale);
context.createConfigurationContext(configuration);
} else {
configuration.locale = locale;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
configuration.setLayoutDirection(locale);
}
}
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
return new LanguageContextWrapper(context);
}
In activity class override following method
override fun attachBaseContext(base: Context) {
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N_MR1) {
super.attachBaseContext(LanguageContextWrapper.wrap(base, Locale.getDefault().language))
} else {
super.attachBaseContext(base)
}
}
And after change language we have to recreate activity, we need to write following code
fun recreateActivity(){
if (Build.VERSION.SDK_INT in 26..27) {
if (Locale.getDefault().language == "ar" ||
Locale.getDefault().language == "iw" ||
Locale.getDefault().language == "ur")
window.decorView.layoutDirection = View.LAYOUT_DIRECTION_RTL
else
window.decorView.layoutDirection = View.LAYOUT_DIRECTION_LTR
}
recreate()
}