Font size of TextView in Android application changes on changing font size from native settings

前端 未结 14 2101
抹茶落季
抹茶落季 2020-12-04 07:47

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

14条回答
  •  粉色の甜心
    2020-12-04 08:29

    in android 8 this solution work for me

    add this code in base activity

    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(newBase);
        final Configuration override = new Configuration(newBase.getResources().getConfiguration());
        override.fontScale = 1.0f;
        applyOverrideConfiguration(override);
    }
    

    source https://stackoverflow.com/a/57225687/7985871

提交回复
热议问题