How to disable zoom in WebView

PAOLOSANTINONPAOLOSANTINON ITMember ✭✭
edited September 2015 in Xamarin.Forms

In my app (Android, iOS and Windows Phone) I have a Page with a WebView that loads content from a URL (an html page). The WebView takes all the space in my page and it's all working perfectly except for one thing: I want to disable zooming in WebView (both via double tap and pinch to zoom).

Anybody knows how to do it?

Tagged:

Answers

  • g.michg.mich GRMember

    Please post your solution . I have the same problem . Thanks

  • PAOLOSANTINONPAOLOSANTINON ITMember ✭✭

    Sorry, but I left it as it was!

  • K_RensVZKK_RensVZK BEMember

    WebView.SetInitialScale(100); stops the zooming ability for me.

  • TouchBoarderTouchBoarder NOMember ✭✭

    iOS
    //disable zoom in iOS WKWebView script: https://stackoverflow.com/a/41741125/546054

    var source = "var meta = document.createElement('meta');" +
    "meta.name = 'viewport';" +
    "meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" +
    "var head = document.getElementsByTagName('head')[0];" + "head.appendChild(meta);";
    
    var script = new WKUserScript(new NSString(source), WKUserScriptInjectionTime.AtDocumentEnd, true);
    
    wkWebView.Configuration.UserContentController.AddUserScript(script);
    

    Android

    webView.Settings.BuiltInZoomControls = false;

Sign In or Register to comment.