1

I am creating an application where I have to resize the content of a webview. Everything works fine until I load inside the webView a mobile page. No matter what value I set to setInitialScale(n) the content of webView is not resizing. Below is the code I am using:

webView.getSettings().setSupportZoom(true);  
webView.getSettings().setUseWideViewPort(true);
webView.setInitialScale(33);
webView.loadUrl("http://m.jurnalul.ro");

Is there any possibility to zoom out or in the content of a WebView that contains a mobile page.

Thank you very much

Brais Gabin
  • 5,827
  • 6
  • 57
  • 92

1 Answers1

1

Have you tried :

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);

switch (metrics.densityDpi) {
case DisplayMetrics.DENSITY_HIGH:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
    break;

case DisplayMetrics.DENSITY_MEDIUM:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    break;

case DisplayMetrics.DENSITY_LOW:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.CLOSE);
    break;

default:
    webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.MEDIUM);
    break;
}
ChristopheCVB
  • 7,269
  • 1
  • 29
  • 54
  • Thank you for your answer. I have tried the code you write it and is still not working. I don't think is possible to resize the content of a web page designed for mobile use. I think that if the page width fits the screen width then the scale option are disabled. – constantin cara Aug 02 '11 at 07:37
  • This solution does not provide for a precise zoom factor. – Lars Blumberg May 20 '13 at 10:11