自从我在移动设备上升级到
android oreo后,我的RTL支持应用程序无效.它正在将字符串更改为阿拉伯语,但不会更改布局方向.但如果我将同一个RTL转移到低于oreo的任何设备,一切正常.其他人遇到过这个问题?关于这个bug和解决方法还有任何官方声明吗?
下面是我更改区域设置的方法
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; }