当前位置: 代码迷 >> Android >> 关于安卓的触屛监听的一个有关问题
  详细解决方案

关于安卓的触屛监听的一个有关问题

热度:54   发布时间:2016-04-28 06:53:51.0
关于安卓的触屛监听的一个问题
我想得到滑动的距离。  我的想法是得到按下的点的坐标和抬起点的坐标,但是不知道用什么函数比较好。求大神指导
------解决方案--------------------
@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);
  相关解决方案