Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between onScroll() and onFling() of GestureDetector

What is the difference between onScroll() and onFling() in the GestureDetector interface? When I print out the events they are showing the exact same things. At least the last onScroll() and the onFling().

The only true difference I noticed is that onScroll() is called much more often, fling always just one time.

like image 256
Mulgard Avatar asked Jan 22 '15 21:01

Mulgard


People also ask

What is the difference between onScroll and onFling callbacks in terms of the number of times the callback is called per gesture?

onFling: is that the user lifts his finger in the end of the movement (that is the reason for what onFling is called one time). onScroll: is the general process of moving the viewport (that is, the 'window' of content you're looking at).

What is onFling Android?

onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) Notified of a fling event when it occurs with the initial on down MotionEvent and the matching up MotionEvent . abstract void. onLongPress(MotionEvent e) Notified when a long press occurs with the initial on down MotionEvent that trigged it.


1 Answers

The difference between Scroll and fling

onFling: is that the user lifts his finger in the end of the movement (that is the reason for what onFling is called one time).

onScroll: is the general process of moving the viewport (that is, the 'window' of content you're 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 content you're looking at). When scrolling is in both the x and y axes, it's called panning. The sample application provided with this class, InteractiveChart, illustrates two different types of scrolling, dragging and flinging:

  • Dragging is the type of scrolling that occurs when a user drags her finger across the touch screen. Simple dragging is often implemented by overriding onScroll() in GestureDetector.OnGestureListener. For more discussion of dragging, see Dragging and Scaling.

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

like image 89
Jorgesys Avatar answered Oct 13 '22 01:10

Jorgesys