I am calling wv.zoomIn() in my fragment's onCreateView, and it is having no effect.
Full story ...
My fragment contains a slider which I use to programmatically zoomIn/zoomOut a webview. This is working fine.
I now want to store the last used zoom level, and apply it to the webview next time it is displayed. So in the onCreateView I am retrieving the zoom level and calling zoomIn an appropriate number of times.
public View onCreateView(LayoutInflater inflater...
...
if (savedZoom > defaultZoom) {
for (int i=defaultZoom; i< savedZoom; i++) {
MyLog.d("zooming in"); // appears x times in log as expected
boolean zoominResult = wv.zoomIn();
MyLog.d("zoominResult = "+zoominResult); // shows zoomIn returns FALSE
}
}
The logs confirm that wv.zoomIn() is being called the correct number of times, but the displayed webview is still at the default zoom.
Any suggestions such as a way to call the zoomIn() post-render, or an alternative way to preserve and restore the zoom settings of the webview?
I think this code will help:
webView.clearView();
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("< your URL >");
int scale = (int) (100 * webView.getScale());
webView.setInitialScale(scale);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setBuiltInZoomControls(true);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With