GestureDetector类定义了许多触摸事件。包括
1.boolean onDoubleTap(MotionEvent e)解释:双击的第二下Touch down时触发
2.boolean onDoubleTapEvent(MotionEvent e)解释:双击的第二下Touch down和up都会触发,可用e.getAction()区分。
3.boolean onDown(MotionEvent e)解释:Touch down时触发
4.boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)解释:Touch了滑动一点距离后,up时触发。
5.void onLongPress(MotionEvent e)解释:Touch了不移动一直Touch down时触发
6.boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)解释:Touch了滑动时触发。
7.void onShowPress(MotionEvent e)解释:Touch了还没有滑动时触发(与onDown,onLongPress)比较onDown只要Touch down一定立刻触发。而Touchdown后过一会没有滑动先触发onShowPress再是onLongPress。所以Touchdown后一直不 滑动,onDown->onShowPress->onLongPress这个顺序触发。
8.boolean onSingleTapConfirmed(MotionEvent e)
9.boolean onSingleTapUp(MotionEvent e)解释:上面这两个函数都是在touch down后又没有滑动(onScroll),又没有长按(onLongPress),然后Touchup时触发。
点击一下非常快的(不滑动)Touchup:onDown->onSingleTapUp->onSingleTapConfirmed
点击一下稍微慢点的(不滑 动)Touchup:onDown->onShowPress->onSingleTapUp->onSingleTapConfirmed
GestureDetector探测当前用户各种不同的操作手势,通过 GestureDetector.OnGestureListener callback来获取当前被触发的操作手势(Single Tap Up、Show Press、Long Press、Scroll、Down、Fling)。