我想得到滑动的距离。 我的想法是得到按下的点的坐标和抬起点的坐标,但是不知道用什么函数比较好。求大神指导
------解决方案--------------------
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
mGestureDetector.onTouchEvent(ev);
return false;
}
private class MyGestureDetector extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY){
//在这里获取距离
}
}
mGestureDetector = new GestureDetector(mContext.getApplicationContext(),
new MyGestureDetector(), null, false);