Last active
November 24, 2021 15:44
-
-
Save TorkelV/254d6e42e15e427a9213d70f762b37f7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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