禁用枪王变焦/放大还原上的WebView [英] Disable Double Tap Zoom/Unzoom on a webview

查看:165
本文介绍了禁用枪王变焦/放大还原上的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android上,我正在使用的WebView显示图表的API海军报设计。

On Android, I'm am using a webview to display a chart designed by the API flot.

我用这个code:

    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.graphique);

    // Get a reference to the declared WebView holder
    WebView webview = (WebView) this.findViewById(R.id.webView1);

    // Get the settings
    WebSettings webSettings = webview.getSettings();

    // Enable Javascript for interaction
    webSettings.setJavaScriptEnabled(true);

    // Make the zoom controls visible
    //webSettings.setBuiltInZoomControls(true);

    // Allow for touching selecting/deselecting data series
    webview.requestFocusFromTouch();

    // Set the client
    webview.setWebViewClient(new WebViewClient());
    webview.setWebChromeClient(new WebChromeClient());
    webview.setBackgroundColor(0);

    webview.getSettings().setLoadWithOverviewMode(true);
    webview.getSettings().setUseWideViewPort(true);
    // Load the URL
    webview.loadUrl("file:///android_asset/graph.html");

该图显示正确和填充整个web视图即使宽度和高度是不一样的,在开始(感谢setLoadWithOverviewMode(真)和setUseWideViewPort(真))。

The graph is displayed correctly and fills the entire webview even if the width and height are not the same at start (thanks to setLoadWithOverviewMode(true) and setUseWideViewPort(true)).

但用户仍然可以放大,缩小和取消缩放图形双攻就可以了。

But the user can still zoom and unzoom the graph by double tapping on it.

我想prevent这个动作,我试图把我的WebView可点击=假,可聚焦=虚假和focusableintouchmode =假,但它不能正常工作。

I want to prevent this action, I tried to put my webview to clickable=false, focusable=false and focusableintouchmode=false but it doesn't work.

我想这也是:

webview.getSettings().setBuiltInZoomControls(false);

不过,这是行不通的。你有什么线索吗?

But it doesn't work. Do you have any clue ?

推荐答案

尝试设置

webView.getSettings().setUseWideViewPort(false);

和处理规模手动设置的宽度。

and deal with scale manually to fit the width..

这篇关于禁用枪王变焦/放大还原上的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆