关键代码:
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
VelocityTracker vt = VelocityTracker.obtain(); //1.获得VelocityTracker
vt.addMovement(event); //2.添加要监听的event
vt.computeCurrentVelocity(1000); //3.计算速率
Log.d(TAG, vt.getXVelocity()+"--"+vt.getYVelocity()); //4.得到x方向和y方向的速率
return super.onTouchEvent(event);
}