How To Have Both Swipe And Touch Events For Webview?
Hello guys i am creating epub reader and i have customised my WebView to scroll horizontal, now i want to stop the default scroll and do scrolling programatically based on swipe gu
Solution 1:
By your implementation of onTouch()
, the onTouchEvent()
method of the View
will not be called, preventing its default touch behaviour to run.
Change the following:
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
To this:
public boolean onTouch(View v, MotionEvent event) {
gestureDetector.onTouchEvent(event);
return v.onTouchEvent(event);
}
Solution 2:
If you want to stop default scroll action write this:
gestureDetector.onTouchEvent(event);
if(event.getAction()== MotionEvent.ACTION_MOVE) {
returntrue;
} else {
return v.onTouchEvent(event);
}
Post a Comment for "How To Have Both Swipe And Touch Events For Webview?"