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
转载来源:http://lujl1988.iteye.com/blog/759927
分享到:
相关推荐
GestureDetector手势识别类详解,帮助理解快速实现复杂手势需求
GestureDetector的工作原理是,当我们接收到用户触摸消息时,将这个消息交给GestureDetector去加工,我们通过设置侦听器获得GestureDetector处理后的手势。 GestureDetector提供了两个侦听器接口,OnGestureListener...
基础 GestureDetector的工作原理是,当我们接收到用户触摸消息时,将这个消息交给GestureDetector去加工,我们通过设置侦听器获得GestureDetector处理后的手势。 GestureDetector提供了两个侦听器接口,...
可以看到,onFling()方法有四个参数,arg0和arg1上面代码用到了,比较好理解。参数arg3和arg4是做什么用的呢?arg3和arg4实际上是X轴和Y轴上的移动速度,单位是像素/秒。结合这两个参数,可以判断滑动的速度,从而做...
可以看到,onFling()方法有四个参数,arg0和arg1上面代码用到了,比较好理解。参数arg3和arg4是做什么用的呢?arg3和arg4实际上是X轴和Y轴上的移动速度,单位是像素/秒。结合这两个参数,可以判断滑动的速度,从而做...
本示例演示在Android中实现图片左右滑动效果。关于滑动效果,在Android中用得比较多,本示例实现的滑动效果是使用ViewFlipper来实现的,当然也可以使用其它的View来实现。...import android.view.GestureDetector;impo
2、GestureDetector与ScaleGestureDetector 3、Bitmap的一下基本用法 4、这里只需要重写view的onDraw就可实现全部功能 可以发现这个其实没什么难度,主要就是一些位置的计算。 为了能便于理解首先把要用到的知识点...
3.1.4 VelocityTracker、GestureDetector和Scroller 126 3.2 View的滑动 129 3.2.1 使用scrollTo/scrollBy 129 3.2.2 使用动画 131 3.2.3 改变布局参数 133 3.2.4 各种滑动方式的对比 133 3.3 弹性滑动 135 ...
3.1.4 VelocityTracker、GestureDetector和Scroller / 126 3.2 View的滑动 / 129 3.2.1 使用scrollTo/scrollBy / 129 3.2.2 使用动画 / 131 3.2.3 改变布局参数 / 133 3.2.4 各种滑动方式的对比 / 133 ...
25.4.2 GestureDetector和OnGestureListener 25.4.3 自定义手势 25.4.4 Gestures Builder应用程序 25.5 参考资料 25.6 小结 第26章 传感器 26.1 什么是传感器 26.1.1 检测传感器 26.1.2 ...
25.4.2 GestureDetector和OnGestureListener 25.4.3 自定义手势 25.4.4 Gestures Builder应用程序 25.5 参考资料 25.6 小结 第26章 传感器 26.1 什么是传感器 26.1.1 检测传感器 26.1.2 ...