I want to specify my own text size in my application, but I am having a problem doing this.
When I change the font size in the device settings, the font size of my
this may help. add the code in your custom Application or BaseActivity
/**
* 重写 getResource 方法,防止系统字体影响
*
* @return
*/
@Override
public Resources getResources() {
Resources resources = super.getResources();
if (resources != null && resources.getConfiguration().fontScale != 1) {
Configuration configuration = resources.getConfiguration();
configuration.fontScale = 1;
resources.updateConfiguration(configuration, resources.getDisplayMetrics());
}
return resources;
}
however, Resource#updateConfiguration is deplicated in API level 25, which means it will be unsupported some day in the future.