android - GestureDetector的onScroll()和onFling()的区别

标签 android android-gesture

GestureDetector接口(interface)中的onScroll()onFling()有什么区别? 当我打印出事件时,它们显示的是完全相同的东西。至少最后一个 onScroll()onFling()

我注意到的唯一真正区别是 onScroll() 被更频繁地调用,总是只调用一次。

最佳答案

Scrollfling的区别

onFling:是用户在移动结束时抬起手指(这就是调用一次onFling的原因)。

onScroll:是移动视口(viewport)(即您正在查看的内容的“窗口”)的一般过程。

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.

关于android - GestureDetector的onScroll()和onFling()的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28098737/

相关文章:

Android 应用程序链接在 android 12 中不起作用总是在浏览器中打开

android - 如何在快速滚动时自定义 Alpha 索引器

java - 双指缩放仅放大到中心

android - 捏缩放 Android 中的多点触控功能

android - 必须下载什么手势文件以及如何下载?

java - 华为系统文件"Source code does not match the bytecode"

android - 处理程序与线程

Android 在 Spinner 中更改文本颜色

android - 如何防止双击 ListView?

Android canvas - 在点之间绘制圆弧并从路径中删除圆弧