On Android, I'm am using a webview to display a chart designed by the API flot.
I'm using this 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");
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.
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.
I tried this also :
webview.getSettings().setBuiltInZoomControls(false);
But it doesn't work. Do you have any clue ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…