Android "swipe" vs "fling"
Asked Answered
T

2

42

In the Android Developers gesture design section, the term "swipe" is used.
In the developer section, the term "fling" is used.

Are these terms synonymous? From what I have found, I believe they are, but nowhere is it explicitly said one way or the other.

That said, if I want to implement functionality for a "swipe," should I implement onFling in GestureDetector?

Thence answered 3/4, 2014 at 16:31 Comment(0)
Q
26

onFling() will get executed when a user makes a "fling" motion, and said motion has a velocity with it to determine the type of fling it was. However, if a user simply touches the device and moves slowly across the screen, that would not be considered a fling, but a swipe.

It comes down to what type of motion you expect the users to perform. The ideal case would be to implement the onFling() function to capture that motion, and also implement onDrag() and onDragFinished() to capture the more subtle motions that should still be considered a swipe.

Quincentenary answered 3/4, 2014 at 16:38 Comment(2)
What about when a user scrolls? From what you've described, a "swipe" sounds like it encompasses scrolling. Is that true?Thence
That is correct. It follows the same logic that users may scroll differently so having onFling and onDrag implemented would safely capture all input. Also, scrolling is generally executed by swiping or flinging up or down, so you can have checks inside those functions to check the direction of the motion and act accordingly.Quincentenary
B
38

Drag, swipe, or fling details

Swipe gesture activities vary based on context. The speed at which a gesture is performed is the primary distinction between Drag, Swipe, and Fling.

  • Drag: Fine gesture, slower, more controlled, typically has an on-screen target
  • Swipe: Gross gesture, faster, typically has no on-screen target
  • Fling: Gross gesture, with no on-screen target

Gesture velocity impacts whether the action is immediately reversible.

  • A swipe becomes a fling based on ending velocity and whether the affected element has crossed a threshold (or point past which an action can be undone).
  • A drag maintains contact with an element, so reversing the direction of the gesture will drag the element back across the threshold.
  • A fling moves at a faster speed and removes contact with the element while it crosses the threshold, preventing the action from being undone.

from https://www.google.com/design/spec/patterns/gestures.html

Beneath answered 14/8, 2015 at 4:8 Comment(0)
Q
26

onFling() will get executed when a user makes a "fling" motion, and said motion has a velocity with it to determine the type of fling it was. However, if a user simply touches the device and moves slowly across the screen, that would not be considered a fling, but a swipe.

It comes down to what type of motion you expect the users to perform. The ideal case would be to implement the onFling() function to capture that motion, and also implement onDrag() and onDragFinished() to capture the more subtle motions that should still be considered a swipe.

Quincentenary answered 3/4, 2014 at 16:38 Comment(2)
What about when a user scrolls? From what you've described, a "swipe" sounds like it encompasses scrolling. Is that true?Thence
That is correct. It follows the same logic that users may scroll differently so having onFling and onDrag implemented would safely capture all input. Also, scrolling is generally executed by swiping or flinging up or down, so you can have checks inside those functions to check the direction of the motion and act accordingly.Quincentenary

© 2022 - 2024 — McMap. All rights reserved.