View的位置参数
MotionEvent
包括三种类型:
- ACTION_DOWN
- ACTION_MOVE
- ACTION_UP
getX/getY 相对于View的坐标
getRawX/getRawY 相对于手机屏幕的坐标
TouchSlop-滑动的最小距离
获取该常量(8dp)1ViewConfiguration.get(getContext()).getScaledTouchSlop()
VelocityTracker-速度追踪
获取1VelocityTracker mVelocityTracker=VelocityTracker.obtain();
测速123456//跟踪当前事件mVelocityTracker.addMovement(event);//获取速度mVelocityTracker.computeCurrentVelocity(1000);//设置测速时间段float xVelocity=mVelocityTracker.getXVelocity();float yVelocity=mVelocityTracker.getYVelocity();
回收123//回收,释放内存mVelocityTracker.clear();mVelocityTracker.recycle();
GestureDetector-手势检测
|
|
接管onTouchEvent方法12boolean consume=mGestureDetector.onTouchEvent(event);return consume;
Tip: 监听滑动相关,自己在onTouchEvent中实现;监听双击之类,用GestureDetector
Scroller-弹性滑动
|
|