Flutter:如何在Web视图中启用手势? [英] Flutter: how to enable gestures in a web view?
问题描述
我想放大或缩小以在Flutter中放大我的Web视图页面. 我在网上做了一些研究,然后在某个地方找到了它:
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:
尽管捏合和缩放内置于WebView(Android)和UIWebView(iOS),但它们需要打开". 在Android中,该插件需要调用以下内容:
"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.
在iOS中,该插件需要调用以下内容:
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?
推荐答案
在webview声明后放置zoom方法,请参考以下代码
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);
}
这篇关于Flutter:如何在Web视图中启用手势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!