问题
I found the way to enable/disable zoom controls in Android WebView from following question.
How to remove zoom buttons on Android webview?
I'm using NativeScript and I don't see similar method in NativeScript WebView. Is there any way I can access the methods of Android WebView from NativeScript? Or, is there any other way?
Thanks.
回答1:
You can get hold of the actual android trough the android
property of your WebView. So you can probably use something like that in the loaded event:
var webView = page.getViewById("webViewID");
if(webView.android) { // in IOS android will be undefined
webView.android.getSettings().setBuiltInZoomControls(false);
}
回答2:
Just add this meta tag to header of your html
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
回答3:
In NS + Angular:
import { WebView, LoadEventData } from "ui/web-view";
...
//Get the element ref from the view #webView
@ViewChild("webView") webView: ElementRef;
...
//Get the real object type casted
let webview: WebView = this.webView.nativeElement;
if(webview.android) {
webview.android.getSettings().setBuiltInZoomControls(false);
}
来源:https://stackoverflow.com/questions/36808087/nativescript-how-do-i-disble-zoom-controls-in-webview