1 回答
TA贡献2036条经验 获得超8个赞
我设法克服了这个问题,但在活动中覆盖了 onConfigurationChanged 并在清单中添加了这一行
android:configChanges="orientation|screenSize|layoutDirection|locale"
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
Locale locale = new Locale(presenter.getLanguage());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
newConfig.setLocale(locale);
Locale.setDefault(locale);
newConfig.setLayoutDirection(locale);
this.createConfigurationContext(newConfig);
} else {
newConfig.locale = locale;
Locale.setDefault(locale);
newConfig.setLayoutDirection(locale);
getBaseContext().getResources().updateConfiguration(newConfig, getBaseContext().getResources().getDisplayMetrics());
}
}
添加回答
举报