NativeScript: How do I disble zoom controls in WebView?

橙三吉。 提交于 2019-12-06 14:29:36

问题


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

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