【问题标题】:Flutter: how to enable gestures in a web view?Flutter:如何在 Web 视图中启用手势?
【发布时间】:2019-01-08 18:20:35
【问题描述】:

我想在 Flutter 中放大和缩小我的网页视图页面。 我在网上做了一些研究,我在某个地方找到了这个:

“虽然捏合和缩放是 WebView (Android) 和 UIWebView (iOS) 的内置功能,但它们需要“开启”。 在Android中,插件需要调用如下:

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

在iOS中,插件需要调用如下:

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

问题是我不知道将这段代码放在哪里/我不知道如何使用它。 谁能帮帮我?

【问题讨论】:

标签: webview flutter zooming gestures


【解决方案1】:

将缩放方法放在webview声明后,请参考以下代码

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

【讨论】:

猜你喜欢
  • 2020-10-19
  • 1970-01-01
  • 2021-05-06
  • 2020-07-06
  • 1970-01-01
  • 2021-01-18
  • 1970-01-01
  • 2021-08-21
  • 1970-01-01
相关资源
最近更新 更多