Flutter: how to enable gestures in a web view?

我是研究僧i 提交于 2020-02-01 09:17:23

问题


I would like to pinch in and out to zoom in my web view page in Flutter. I did some researches online and I found this somewhere:

"Although pinch and zoom are built-in to WebView (Android) and UIWebView (iOS), they need to be "switched-on". In Android, the plugin needs to call the following:

this.webView.getSettings().setBuiltInZoomControls(true);
this.webView.getSettings().setSupportZoom(true); to allow pinch/zoom.

In iOS, the plugin needs to call the following:

self.webview.scalesPageToFit = YES; to allow pinch/zoom."

The problem is that I don't know where to put this code/I don't know how to use it. Can anyone help me, please?


回答1:


Put the zoom method after webview declaration,Please refer below code

public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.show_web_view);

        webView = (WebView) findViewById(R.id.webView1);
        WebSettings webSettings = webView.getSettings();
        webSettings.setBuiltInZoomControls(true);
        webSettings.setSupportZoom(true);
}


来源:https://stackoverflow.com/questions/51628868/flutter-how-to-enable-gestures-in-a-web-view

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