VelocityTracker
速度追踪,包括水平和竖直方向的速度,在onTounchEvent方法中调用
VelocityTracker velocityTracker =VelocityTracker.obtain();
velocityTracker.addMovement(event)
获取速度:速度=(终点位置-起点位置)/时间段
velocityTracker.computeCurrentVelocity(1000);
float x=velocityTracker.getXVelocity();
float y=velocityTracker.getXVelocity();
结束时候记得是释放资源
velocityTracker.clear();
velocityTracker.recycle();
举例
VelocityTracker velocityTracker;
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
velocityTracker = VelocityTracker.obtain();
velocityTracker.addMov

最低0.47元/天 解锁文章
1658

被折叠的 条评论
为什么被折叠?



