本篇文章是面對同一個機子的字體大小設(shè)置不同而進(jìn)行的適配。

具體操作方法:
在Application中重寫以下兩種方法
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (newConfig.fontScale != 1)//非默認(rèn)值
getResources();
super.onConfigurationChanged(newConfig);
}
@Override
public Resources getResources() {
Resources res = super.getResources();
if (res.getConfiguration().fontScale != 1) {//非默認(rèn)值
Configuration newConfig = new Configuration();
newConfig.setToDefaults();//設(shè)置默認(rèn)
res.updateConfiguration(newConfig, res.getDisplayMetrics());
}
return res;
}