| Gesture | Android event | Delivered to |
|---|---|---|
Pinch (Look and Pinch selection) | ACTION_DOWN, then ACTION_MOVE while held, then ACTION_UP on release | onTouchEvent() |
Forward swipe, backward swipe, when routed to scrolling | ACTION_SCROLL carrying AXIS_VSCROLL | onGenericMotionEvent() |
Left swipe, right swipe, when routed to scrolling | ACTION_SCROLL carrying AXIS_HSCROLL | onGenericMotionEvent() |
Thumb tap | No event delivered to your app | N/A |
| Swipe | Axis | Natural scrolling on | Natural scrolling off |
|---|---|---|---|
Forward | AXIS_VSCROLL | Negative | Positive |
Backward | AXIS_VSCROLL | Positive | Negative |
Left | AXIS_HSCROLL | Positive | Negative |
Right | AXIS_HSCROLL | Negative | Positive |
ScrollView and HorizontalScrollView support ordinary scrolling with these events, so you can use them without a microgesture-specific handler. To implement custom scrolling in your own View, override onGenericMotionEvent() and handle ACTION_SCROLL.AXIS_VSCROLL for vertical scrolling or AXIS_HSCROLL for horizontal scrolling. The value is in scroll units, not pixels. Multiply it by ViewConfiguration.get(context).getScaledVerticalScrollFactor() or getScaledHorizontalScrollFactor(), then apply the result to your content’s scroll position. The delivered value already reflects the device’s natural-scrolling setting. Follow your view’s axis convention: ScrollView subtracts the vertical delta from its scroll position, and HorizontalScrollView adds the horizontal delta.true for events your view handles. Pass every other event to the superclass. This statement, taken from the end of the AOSP method, delegates unhandled events to the superclass inside the callback:return super.onGenericMotionEvent(event);
AXIS_VSCROLL and AXIS_HSCROLL as delivered, per the table above; do not invert or hardcode a direction.onTouchEvent() misses swipe scrolling. Override onGenericMotionEvent() too, and prefer standard Android scrolling widgets where they fit.