Difference between onScroll () and onFling () GestureDetector

What is the difference between onScroll() and onFling() in the GestureDetector interface? When I print events, they show the same thing. At least the latest onScroll() and onFling() .

The only true difference I noticed is that onScroll() is called much more often, always throwing only once.

+7
android android gesture
source share
1 answer

The difference between Scroll and fling

onFling : this is what the user raises his finger at the end of the movement (this is the reason that onFling is called once).

onScroll : this is the general process of moving the viewport (that is, the β€œwindow” of content you are looking at).

Understand scrolling terminology β€œScrolling” is a word that can take on different meanings in Android depending on the context.

Scrolling is the general process of moving the viewport (that is, the β€œwindow” of the content you are looking at). When scrolling is in both x and y, this is called panning. A sample application provided with this class, InteractiveChart, illustrates two different types of scrolling, drag and drop:

  • Drag and drop is a type of scrolling that occurs when the user drags it with a finger on the touch screen. Often drag and drop is done by overriding onScroll () in the GestureDetector.OnGestureListener. For more discussions of drag and drop, see Drag and Drop.

  • Flinging is a type of scrolling that occurs when the user drags and lifts a finger quickly. After the user lifts his finger, you usually want to keep scrolling (moving the viewport), but slowing down to the viewport stops moving. Drop can be implemented by overriding onFling () in the GestureDetector.OnGestureListener and using the scroller object.

+11
source share

All Articles