user1132897
user1132897

Reputation: 1201

How to set android webview zoom to specific height

I am using a Webview to look at a local image with zoom support and all that. Is there any way that I can make the WebView zoom to only fit the height of the image, instead of the width like it does with my current code? Here is what I have:

WebView image = (WebView)findViewById(R.id.map);
    image.getSettings().setBuiltInZoomControls(true);
    image.getSettings().setLoadWithOverviewMode(true);
    image.getSettings().setUseWideViewPort(true);
    image.setLayoutParams(new     LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
    image.loadUrl("file:///android_asset/image.png");

Upvotes: 1

Views: 2909

Answers (1)

Frank Sposaro
Frank Sposaro

Reputation: 8531

Try using the webView Settings

use the webSettings class

webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

Check out Set zoom for Webview

Update: as setDefaultZoom deprecated you need to use another settings

Upvotes: 2

Related Questions