So recently I was trying to build my app for Android 6 by setting the android:targetSdkVersion="23"
in the manifest file, everything went well but then I noticed the strange behavior of webview.
In my app I first load some content into the webview using the webview.LoadData (someHtmlContent, "text/html; charset=UTF-8", null);
then at any point user can change the text size by using some buttons in the menu of the app. These buttons work like this:
webview.LoadUrl ("javascript:" + "document.getElementsByTagName(\"body\")[0].style.fontSize = \"" + size + "%\";");
size
is a string that can be anything from 100%
(Initial size) to 110%
, 120%
and ...
This method effectively injects JavaScript into the already existing content (HTML) and works perfectly on Android 5 and lower but not on Android 6.
In Android 6, when user clicks a button that injects JS, it just replaces the content of webview with the size
variable.
Can anyone help?