Android中activity触摸操作dispatchTouchEvent

Android中activity触摸操作dispatchTouchEvent

触摸事件先进行此操作


float downX = 0, downY = 0;
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
    switch (ev.getAction()){
        case MotionEvent.ACTION_DOWN :
            downX = ev.getX();
            downY = ev.getY();
            break;
        case MotionEvent.ACTION_MOVE:
            break;
        case MotionEvent.ACTION_UP:
            break;
    }
    return super.dispatchTouchEvent(ev);
}

你可能感兴趣的:(Android)