APP字体不随系统字体大小变化
2019-04-28 07:17:52 星期日app字体不随着系统设置变大变小
在基类BaseActivity 里面设置即可,重写getResources()方法
具体代码如下
原文地址:https://www.jianshu.com/p/059f3bad61b2
@Override
public Resources getResources() {
Resources resources = super.getResources();
Configuration newConfig = resources.getConfiguration();
DisplayMetrics displayMetrics = resources.getDisplayMetrics();
if (resources != null && newConfig.fontScale != 1) {
newConfig.fontScale = 1;
if (Build.VERSION.SDK_INT >= 17) {
Context configurationContext = createConfigurationContext(newConfig);
resources = configurationContext.getResources();
displayMetrics.scaledDensity = displayMetrics.density * newConfig.fontScale;
} else {
resources.updateConfiguration(newConfig, displayMetrics);
}
}
return resources;
}