I have a WebView and 2 urls to open it it. What I want to do is, when i set a zoom level for 1st url, and then i go to 2nd url, it should also have the same zoom level. Right now, the zoom level resets for both.
Thanks, Farha
This example demonstrate about How to enable webview zoom controls in android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml.
webSettings. setBuiltInZoomControls(true); webSettings. setSupportZoom(true);
webview. getSettings(). setLoadWithOverviewMode(true); This will cause the webview to be zoomed out initially.
this will be applicable in this scenario i believe
mWebView.setInitialScale(ZOOM_LEVEL);
where ZOOM_LEVEL for example can be 25 for 25% 150 for 150%
use the webSettings class
webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
Notice that although webSettings is available since API Level 1, WebSettings.ZoomDensity is available since API Level 7. Works well for all device resolutions.
Also, in order to enable zoom on the webView, add the following code:
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