Skip to content

Instantly share code, notes, and snippets.

@michpohl
Last active May 6, 2019 16:09
Show Gist options
  • Save michpohl/5fe5dc6322717cc936c50f0e8fde21dd to your computer and use it in GitHub Desktop.
Save michpohl/5fe5dc6322717cc936c50f0e8fde21dd to your computer and use it in GitHub Desktop.
how to override Accessibility fontScale setting in Android

Just check what sizing the fontScale is set to and change it to whatever we want. Then We have to reapply the configuration. This is an example method to put into an activity:

override fun attachBaseContext(newBase: Context?) {
        super.attachBaseContext(newBase)
        val conf = newBase!!.resources.configuration
        if (conf.fontScale > 1) {
            conf.fontScale = 1F
        applyOverrideConfiguration(conf)
        }
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment