1

I have found a similar accept answer in: Disable scrolling in webview?

Sample code is:

// disable scroll on touch
webview.setOnTouchListener(new View.OnTouchListener() {
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return (event.getAction() == MotionEvent.ACTION_MOVE);
    }
});

But the accept answer don't satisfy my requirements, because the video & audio progress bar's touch move event is also disable(embed in my WebView), so I can't drag the progress bar.

Isn't there another way to solve this? Looking forward to your reply! Thanks!

Community
  • 1
  • 1
codezjx
  • 9,012
  • 5
  • 47
  • 57

1 Answers1

2

I try all the way in this question: Disable scrolling in webview?

And finally i found two way on the bottom:


The first one (answered by GDanger): Extends WebView and override overScrollBy() method and return false.

public class NoScrollWebView extends WebView {
    ...
    @Override
    public boolean overScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, 
                                int scrollRangeX, int scrollRangeY, int maxOverScrollX, 
                                int maxOverScrollY, boolean isTouchEvent) {
        return false;
    }
}

The second one (answered by steelbytes): override onScrollChanged() method.

@Override
protected void onScrollChanged(int l, int t, int oldl, int oldt) {
    if (bAllowScroll) {
        super.onScrollChanged(l, t, oldl, oldt);
    } else if (l! = 0 || t != 0) {
        super.scrollTo(0, 0);
    }
}
Community
  • 1
  • 1
codezjx
  • 9,012
  • 5
  • 47
  • 57