用法:首先让指定的Activity实现Android.view.OnGestureListener,然后在你需要调用GestureDetector的View上,添加onTouchListener,之后setLongClickable(true)即可.
如:
customView.setOnTouchListner(xxxListener);
customView.setLongClickable(true);
之后就可以在onFling方法中设置你想要的手势.
onFling方法参数解释:
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
. The calculated velocity is supplied along the x and y axis in pixels per second.
Specified by: