I have a view that extends FrameLayout and need to be notified of the scrolling events on it. this view has an instance of a class that implements the GestureDetector which is invoked by the overriden onInterceptTouchEvent method.
private class HorizontalScrollListener implements OnGestureListener { @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { ... return false; } @Override public boolean onDown(MotionEvent e) { ... return false; } @Override public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return false; } @Override public void onLongPress(MotionEvent e) { ... System.out.println(); } @Override public void onShowPress(MotionEvent e) {} @Override public boolean onSingleTapUp(MotionEvent e) { return false; } } The only problem is that the onDown and onLongPress methods could get called wheen I try to scroll but the actual onScroll methods never gets invoked.
@Override public boolean onInterceptTouchEvent(MotionEvent event) { boolean result = super.onInterceptTouchEvent(event); if (gestureDetector.onTouchEvent(event)) { return result; } else { return false; } }