android开发浅析GestureDetector
浅析GestureDetector
最近在研究场景切换的动画效果,其中需要用到三连击的动作触发。三连击,即点三下屏幕,但意义上是双击效果。 因此,我需要研究如何识别三连击的动作。
我们知道,一般的View只能响应点击(Click)和长按(LongPress)事件。这是因为View里只暴露了这些listener给我们使用。而实质上,View是在onTouchEvent(MotionEvent event)里对用户的动作做了一定的分析,从而通知我们是发生了点击还是长按等事件。 View里提供的回调在我描述的场景里,并不能满足要求。因此,GestureDetector出场了。我需要对其啃透才能写出自己的ActionDetector。
GestureDetector类可以帮助我们分析用户的动作,和View的onTouchEvent的处理方式差不多,但分析的动作类型更加细致,以下是它的回调接口:
Java代码
1.publicinterfaceOnGestureListener{
2.
3.//Touchdown时触发,e为down时的MotionEvent
4.
5.booleanonDown(MotionEvente);
6.
7.//在Touchdown之后一定时间(115ms)触发,e为down时的MotionEvent
8.
9.voidonShowPress(MotionEvente);
10.
11.//Touchup时触发,e为up时的MotionEvent
12.
13.booleanonSingleTapUp(MotionEvente);
14.
15.//滑动时触发,e1为down时的MotionEvent,e2为move时的MotionEvent
16.
17.booleanonScroll(MotionEvente1,MotionEvente2,floatdistanceX,floatdistanceY);
18.
19.//在Touchdown之后一定时间(500ms)触发,e为down时的MotionEvent
20.
21.voidonLongPress(MotionEvente);
22.
23.//滑动一段距离,up时触发,e1为down时的MotionEvent,e2为up时的MotionEvent 24.
25.booleanonFling(MotionEvente1,MotionEvente2,floatvelocityX,floatvelocityY);
26.
27.}
28.
29.
30.
31.publicinterfaceOnDoubleTapListener{
关键词:android教程android开发android知识android学习GestureDetector ... Android 浅析GestureDetector 一般的View只能响应点击(Click)和长按(LongPress)...
Android 浅析GestureDetector_互联网_IT/计算机_专业资料。Android 浅析GestureDetector由麦可网整理,转载请注明出处 Android 浅析 GestureDetector 一般的 View 只能响应...
关键词:android教程android开发android知识android学习GestureDetector ... 浅析GestureDetector 最近在研究场景切换的动画效果,其中需要用到三连击的动作触发...
Android开发系列—GestureDetector和SimpleOnGestureListener的使用教程(转)_IT/计算机_专业资料。1. 当用户触摸屏幕的时候,会产生许多手势,例如down,up,scroll,filing...
android GestureDetector功能和使用_IT/计算机_专业资料。android GestureDetector功能和使用android 为了增加用户体验,新增了 GestureDetector 类,那该类是做什么用的呢...
Android开发经验总结_计算机软件及应用_IT/计算机_专业资料。ANDROID开发需注意的...手势GestureDetector 的使用 今日推荐 88份文档 2014全国高考状元联手分享状元...
Android系统为我们提供了手势 识别工具GestureDetector,当我们接收到用户触摸消 息时,将这个消息交给GestureDetector去加工,我们 通过设置监听器获得GestureDetector处理后...
对于第二种手势行为, Android 允许开发者添加自己的手势, 并提供相应的 API 识别手势。 一、GestureDetector 类 [java] view plaincopy 1. public class ...
GestureDetector和SimpleOnGestureListener的使用教程_调查/报告_表格/模板_应用... 浅析GestureDetector 暂无评价 1页 免费 Android 浅析GestureDet... 暂无评价 ...
郭志伟 2009 年 12 月创新文档 Android GestureDetector Android Gesture Detector Android Touch Screen 与传统 Click Touch Screen 不同,会有一些手势(Gesture), ...
热门文档