I am overriding onTouchEvent in a layout, and want to handle horizontal movement only.
i.e, if right of left swipe happens then I will show next/prev post and if any vertical movement happens then I wont do anything and the parent scrolling will happen.
How can I do this?
switch (e1.getAction()) {
case MotionEvent.ACTION_DOWN:
offsetX = 0;
offsetY = 0;
startTouchPoint = new Point((int) e1.getX(), (int) e1.getY());
break;
case MotionEvent.ACTION_MOVE:
movement = new Point(Math.abs((int) e1.getX() - startTouchPoint.x), Math.abs((int) e1.getY() - startTouchPoint.y));
if (movement.y < movement.x) { // Horizontal movement
// Custom code to move to prev/next page.
} else { // Vertical movement
// I need android to handle this.
}