Skip to content

Instantly share code, notes, and snippets.

@mvberg
Created October 24, 2013 15:35
Show Gist options
  • Save mvberg/7139423 to your computer and use it in GitHub Desktop.
Save mvberg/7139423 to your computer and use it in GitHub Desktop.
Stop PTR ListView from eating horizontal swipe
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
xDistance = yDistance = 0f;
lastX = ev.getX();
lastY = ev.getY();
break;
case MotionEvent.ACTION_MOVE:
final float curX = ev.getX();
final float curY = ev.getY();
xDistance += Math.abs(curX - lastX);
yDistance += Math.abs(curY - lastY);
lastX = curX;
lastY = curY;
// check x vs y swipe distance here
if(xDistance > yDistance)
return false;
}
return super.onInterceptTouchEvent(ev);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment