Propagate the ACTION_DOWN event to the ScrollView so we can stop scrolling after a fling. Fixes issue 2892.

This commit is contained in:
Andrew Chen 2011-01-30 22:05:47 +00:00
parent 65dc3c7d1b
commit fe8ba6078e
1 changed files with 4 additions and 2 deletions

View File

@ -40,7 +40,8 @@ public class ToggleScrollView extends ScrollView
// currently got. This is based on // currently got. This is based on
// http://stackoverflow.com/questions/2646028/android-horizontalscrollview-within-scrollview-touch-handling // http://stackoverflow.com/questions/2646028/android-horizontalscrollview-within-scrollview-touch-handling
boolean result = super.onInterceptTouchEvent(ev); boolean result = super.onInterceptTouchEvent(ev);
if (mDetector.onTouchEvent(ev)) // Let the original ScrollView handle ACTION_DOWN so we can stop the scroll when someone touches the screen.
if (ev.getAction() == MotionEvent.ACTION_DOWN || mDetector.onTouchEvent(ev))
{ {
return result; return result;
} }
@ -48,7 +49,8 @@ public class ToggleScrollView extends ScrollView
return false; return false;
} }
// Return false if we're scrolling in the x direction // Return false if we're scrolling in the x direction. That is, decline to consume the event and
// let the parent class take a stab at it.
class YScrollDetector extends GestureDetector.SimpleOnGestureListener class YScrollDetector extends GestureDetector.SimpleOnGestureListener
{ {
@Override @Override