@Override
public void onConfigurationChanged(Configuration newConfig) {
if (newConfig.fontScale != 1)
getResources();
super.onConfigurationChanged(newConfig);
}
@Override
public Resources getResources() {
Resources res = super.getResources();
if (res.getConfiguration().fontScale != 1) {
Configuration newConfig = new Configuration();
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());
}
}
return res;
}
Android强制字体不随系统改变而改变
最新推荐文章于 2024-08-28 04:00:08 发布