How to enable zoom controls and pinch zoom in a WebView?

前端 未结 6 1332
醉酒成梦
醉酒成梦 2020-12-02 10:46

The default Browser app for Android shows zoom controls when you\'re scrolling and also allows for pinch zooming. How can I enable this feature for my own Webview?

I

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 11:27

    To enable zoom controls in a WebView, add the following line:

    webView.getSettings().setBuiltInZoomControls(true);
    

    With this line of code, you get the zoom enabled in your WebView, if you want to remove the zoom in and zoom out buttons provided, add the following line of code:

    webView.getSettings().setDisplayZoomControls(false);
    

提交回复
热议问题