NativeScript: How do I disble zoom controls in WebView?

微笑、不失礼 提交于 2019-12-04 19:57:16

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);
}

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">

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);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!