View是Android中所有控件的基类,是一种界面层的控件的一种抽象。
View的位置参数:top左上角纵坐标、left左上角横坐标、right右下角横坐标、bottom右下角纵坐标,相对于View的父容器来说,是一种相对坐标。
x、y是View左上角的坐标,translationX和translationY诗View左上角相对于父容器的偏移量。View在平移时,top、left不改变,改变的是x、y、translationX、translationY。
MotionEvent:手指接触屏幕后所产生的一系列事件。通过点击对象可以得到点击事件发生的x和y坐标,getX/getY 相对于当前View 左上角的x和y坐标,getRawX/getRawY相对于手机屏幕左上角的x和y坐标。
TouchSlop:系统所能识别出的被认为是滑动的最小距离。
ViewConfiguration.get(getContext()).getScaledTouchSlop()
VelocityTracker:速度追踪,用于追踪手指在滑动过程中的速度。
VelocityTracker velocityTracker = VelocityTracker.obtain(); velocityTracker.addMovement(event); velocityTracker.computeCurrentVelocity(1000); int xVelocity = (int) velocityTracker.getXVelocity(); int yVelocity = (int) velocityTracker.getYVelocity();
GestureDetector:手势检测,用于辅助检测用户的单击、滑动、长按、双击等行为。
原文:https://www.cnblogs.com/kyun/p/10767744.html