问题
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