Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webview not scrolling after adding setOnTouchListener

i have a webview with the below code:

WebSettings webSettings = webView.getSettings();
    webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setSupportZoom(false);
    webView.setBackgroundColor(0);
     webView.loadDataWithBaseURL(null, text, "text/html", "UTF-8", null);
webView.setOnTouchListener(onTouchListener);
webView.setVerticalScrollBarEnabled(true);

If i comment webView.setOnTouchListener(onTouchListener); this then webview will scroll but if i add it then the webview will not scroll any reason why so?

EDIT

My Listener

OnTouchListener onTouchListener = new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {

        int action = event.getAction();
        if (action == MotionEvent.ACTION_UP) {
        //do something
        }

        return false;
    }
    };
like image 256
Goofy Avatar asked Dec 16 '22 12:12

Goofy


1 Answers

Your onTouchListener variable is referencing an implementation that always returns true?
From the documentation at http://developer.android.com/reference/android/view/View.OnTouchListener.html
Returns
True if the listener has consumed the event, false otherwise.

Make sure to return false.

like image 129
Telmo Pimentel Mota Avatar answered Dec 21 '22 11:12

Telmo Pimentel Mota