Android“轻扫”与“投掷”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22843671/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android "swipe" vs "fling"
提问by Sean Beach
In the Android Developers gesture design section, the term "swipe" is used.
In the developer section, the term "fling" is used.
在 Android Developers手势设计部分,使用了术语“滑动”。
在开发人员部分,使用了术语“fling”。
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
?
也就是说,如果我想实现“滑动”的功能,我应该onFling
在 中实现GestureDetector
吗?
采纳答案by Adam Alyyan
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.
onFling()
当用户进行“甩动”动作时将被执行,并且该动作有一个速度来确定它是什么类型的甩动。但是,如果用户只是简单地触摸设备并在屏幕上缓慢移动,则不会被视为甩动,而是滑动。
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.
这归结为您希望用户执行的动作类型。理想的情况是实现onFling()
捕获该运动的功能,并实现onDrag()
和onDragFinished()
捕获仍应被视为滑动的更微妙的运动。
回答by Fei Liang
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、Swipe 和 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
- 拖动:精细手势,更慢,更可控,通常有一个屏幕目标
- 滑动:粗略的手势,更快,通常没有屏幕上的目标
- Fling:粗略的手势,没有屏幕上的目标
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