Reputation: 3389
I need to find a way to programmatically zoom out of a WebView on android. Background: I created a phonegap/cordova web app which has a fixed layout. I am using these settings to proper display of the app across devices:
this.appView.getSettings().setUseWideViewPort(true);
this.appView.getSettings().setLoadWithOverviewMode(true);
this.appView.getSettings().setSupportZoom(true);
this.appView.getSettings().setDefaultZoom(ZoomDensity.FAR);
this.appView.getSettings().setBuiltInZoomControls(true);
this.appView.setInitialScale(0);
So far it worked well until a text input field gains focus. Then the app gets rescaled and its impossible to return to the proper view. I searched and worked on this problem for over a day now tried many possible solutions but none worked for me. The approach I am working now on is to make a native call when the text input field looses focus and then to reset the zoom. But I don't know a way to reset the zoom.
webView.zoomOut();
is too slow and webView.setInitialScale(..);
does nothing.
I am looking for something like webView.setZoomLevel(..);
or webView.setScale(..);
but I can not find it in the api.
Pulling out my hair about this.. Please help.
BTW, my meta viewport setting is
<meta name="viewport" content="width=640,height=device-height,target-densityDpi=device-dpi" />
Upvotes: 3
Views: 7061
Reputation: 96
Does one of the responses in this question help? How to set the initial zoom/width for a webview
Brian first suggested: webview.getSettings().setUseWideViewPort(true); and then littleFluffyKitty added: using setInitialScale(50) along with other zoom settings.
Good luck and I hope someone with more wisdom than I have gives you a better answer.
Upvotes: 0
Reputation: 3389
No answer for this question. I guess there is just no way to set the zoom level other than zooming out using the zoomOut()
function. So I had to live with that.
Upvotes: 2