Skip to content

Instantly share code, notes, and snippets.

@TorkelV
Last active November 24, 2021 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TorkelV/254d6e42e15e427a9213d70f762b37f7 to your computer and use it in GitHub Desktop.
Save TorkelV/254d6e42e15e427a9213d70f762b37f7 to your computer and use it in GitHub Desktop.
/*
For some reason the webview does not respect its textZoom property.
It seems like it happens whenever the webviews parent is hidden and made visible again.
Setting the textZoom to a different value and then back fixes the problem..
*/
private fun WebView.fixTextZoomSetting(){
this.apply {
val fontScale = context.resources.configuration.fontScale
if(fontScale != 1f){
val newScale = (fontScale * 100f).toInt()
settings.textZoom = newScale +1
settings.textZoom = newScale
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment