Search code examples
javaandroidgesture

Fling and scroll movements


My View implements onGestureListener to let me be informed when a gesture is done by the user, either if it is a scroll or a fling movement.

When the pointer is moved slowly on the screen, I receive onScroll events as expected.But when the pointer is moved faster, I get several onScroll events before getting the onFling event. As the onFling event passes the event associated with the "up" event, I suppose it is only triggered after the user takes his finger away from the screen.

Ans this causes a not natural behaviour for my application...

My question is : is it possible to suppress all the preceding onScroll events when the move executed by the user is clearly a fling movement?


Solution

  • Problem solved, but the solution doesn't look very clean : in the "onFling" function, I cancel every treatments realized in the "onScroll" function and I only take the "onFling" event into account if one of the velocities is greater than 1000 in absolute value.