【发布时间】:2012-02-19 13:57:29
【问题描述】:
在 Android 上,我正在使用 webview 来显示由 API flot 设计的图表。
我正在使用此代码:
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");
即使宽度和高度在开始时不一样,图形也能正确显示并填充整个 webview(感谢 setLoadWithOverviewMode(true) 和 setUseWideViewPort(true))。
但用户仍然可以通过双击图表来缩放和取消缩放图表。
我想阻止此操作,我尝试将我的 webview 设置为 clickable=false、focusable=false 和 focusableintouchmode=false,但它不起作用。
我也试过这个:
webview.getSettings().setBuiltInZoomControls(false);
但它不起作用。你有什么线索吗?
【问题讨论】: