解决方法在application重写onConfigurationChanged和getResources()两个方法
#onConfigurationChanged
@Override
public void onConfigurationChanged(Configuration newConfig) {
if(newConfig.fontScale!=1)//非默认值
getResources();
super.onConfigurationChanged(newConfig);
}
# getResources()
publicResources getResources() {
Resources res =super.getResources();
if(res.getConfiguration().fontScale!=1) {//非默认值
Configuration newConfig =newConfiguration();
newConfig.setToDefaults();
//设置默认
res.updateConfiguration(newConfig, res.getDisplayMetrics());
if(Build.VERSION.SDK_INT>=Build.VERSION_CODES.JELLY_BEAN_MR1) {
createConfigurationContext(newConfig);
}else{
res.updateConfiguration(newConfig, res.getDisplayMetrics());
}
}
returnres;
}
}