Android设置不被系统设置改变的字体大小

it2022-05-09  66

原因

  从4.0开始,系统设置中“显示”可以对字体大小进行配置,这会影响到TextView等控件中文字显示的大小。

解决方案

  在自定义的Activity中重写getResources方法

@Override public Resources getResources() { Resources res = super.getResources(); Configuration conf = new Configuration(); conf.setToDefaults(); res.updateConfiguration(conf, res.getDisplayMetrics()); return res; }

注意事项

  在任意一个Activity中如上覆盖了getResources方法后,会让其它Activity的字体也变的独立于系统配置。

转载于:https://www.cnblogs.com/maozhige/p/4234935.html

相关资源:Android中App字体大小不随系统改变而改变

最新回复(0)