Android 滑动速度

Jac*_*ack 3 android gesture swipe

计算滑动速度/速率的最佳方法是什么?是否有一些奇特的类或函数可以提供此功能,或者我是否需要通过测量触摸上升和下降来执行此操作?我做了一些搜索,但一无所获——也许我没有正确的术语。

nha*_*man 5

OnGestureListener有以下方法,提供 x 轴和 y 轴的速度:

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
Run Code Online (Sandbox Code Playgroud)

OnGestureListener您可以从文档中实现, or :

如果您想监听所有不同的手势,请实现此接口。如果您只想监听一个子集,那么扩展 GestureDetector.SimpleOnGestureListener 可能会更容易。