10

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 ?

Thordax
  • 1,515
  • 4
  • 24
  • 51

1 Answers1

24

try to set

webView.getSettings().setUseWideViewPort(false);

and deal with scale manually to fit the width..

Maher Abuthraa
  • 15,704
  • 9
  • 68
  • 97