1> 原理:对象
在Android系统中,每一次手势交互都会依照下列顺序执行接口
A、接触屏那一刹那,触发一个MotionEvent事件事件
B、该事件被onTouchListener监听,在onTouch()方法中捕获MotionEvent对象ci
C、经过手势识别器GestureDetector来转发该对象到onGestureListenerit
D、onGestureListener获取该对象,根据该对象封装的信息来作反馈io
2>关键词解释原理
=>MotionEvent: 这个类用于封装手势、触摸笔、轨迹球等等的动做事件。其内部封装了两个重要的属性X和Y,这两个属性分别用于记录横轴和纵轴的坐标。List
=>GestureDetector:用于识别各类手势float
=>OnGestureListener:这是一个手势交互的监听接口,其中提供了多个抽象方法,并根据GestureDetector的手势识别结果调用相对应的方法方法
3>GestureDetector类方法详解
boolean onDoubleTap(MotionEvent e) 双击触发事件
boolean onFling(MotionEvent e1,MotinEvent e2,float velocityX,float velocityY) Touch了滑动一点距离后,up时触发
boolean onScroll(MotionEvent e1,MotionEvent e2.........) Touch了滑动时触发