简体   繁体   中英

Is it possible to pinch to zoom in cordova

There is not a lot of information on this, and the little that I have been able to find is very vague and unhelpful. I imply want a page in my cordova/phonegap app to have an image that can be pinched on to zoom in and pan around. Is this possible and if so, How do I do it?

In the native code just after this line

super.loadUrl(Config.getStartUrl());

Add this

WebSettings settings = super.appView.getSettings();
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(true);
settings.setSupportZoom(true);

You'll need this in native part

import android.webkit.WebSettings;

And in the page you want to zoom, add this

<meta name="viewport" content="user-scalable=yes,initial-scale=1, maximum-scale=5, minimum-scale=0.25/>

This will allow you to zoom the whole page with pinch. Everything inside that page will be zoomed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM