Home » Android » How to disable the bounce effect (blue shade when scroll to end) of webview in android?

How to disable the bounce effect (blue shade when scroll to end) of webview in android?

Posted by: admin June 15, 2020 Leave a comment

Questions:

I found the webview is similar to scroll view , that means when I scroll the view to the end, there will be a blue shade at the end of the view (if it is >4.0) . So, how to disable the behavior of this? How to disable the bounce effect? Thanks.

    mWebView.setWebViewClient(new MyWebViewClient(getActivity()));
    chromeCilent = new MyWebChromeClient(getActivity());
    mWebView.setWebChromeClient(chromeCilent);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setLoadsImagesAutomatically(true);
    mWebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
    mWebView.getSettings().setSupportZoom(false);
    mWebView.getSettings().setSavePassword(false);
    mWebView.getSettings().setBlockNetworkImage(false);
    mWebView.getSettings().setSupportMultipleWindows(false);
    mWebView.getSettings().setAppCacheEnabled(true);
    mWebView.addJavascriptInterface(this, "jsinterface");

    // default go to video page
    mWebView.loadUrl(url);
How to&Answers:

I believe this will work:

mWebView.setOverScrollMode(View.OVER_SCROLL_NEVER);

Answer:

If you want to disable the effect directly in the layout XML resource, you may use:

android:overScrollMode="never"

This is effectively equivalent to Coeffect’s solution.

A benefit of doing this in the xml file rather than in Java code is that you do not need to create an ID of the view to disable the effect. In Java you would need the ID to get reference to the view to disable the effect, while in xml you can directly use the above attribute without having to create the ID.