Search code examples
androidgesturedetector

Android OnGestureListener onScroll MotionEvent


I have a problem with the onScroll event of the OnGestureListener.

the method signature is as follows:

public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY);

The problem is that the MotionEvent e1 seems to be always the same after the first scrolling. When I in example do e1.getX() on the first srcolling it returns 100. when I then stop scrolling and start a second scroll on a different spot of the screen, it also gives 100. only the MotionEvent e2 changes it's value.


Solution

  • e1 will always be the initial motion event for a touch event (The ACTION_DOWN event). e2 is the current motion event.