Android多点触摸 与 手势识别

1. 事件类型

MotionEvent.ACTION_DOWN

MotionEvent.ACTION_MOVE

MotionEvent.ACTION_UP

 

2. 事件传递

public boolean onTouch(View v, MotionEvent event) {
    return false; //表示事件没有触发成功,是不会有后续事件的
    return true; // 要想处理后续事件,需要返回true
}

 

3. 获取多个触摸点坐标

public boolean onTouch(View v, MotionEvent event) {
    // TODO Auto-generated method stub
    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:

            break;
        case MotionEvent.ACTION_MOVE:
            Log.d(TAG, "getPointerCount = " + event.getPointerCount());
            //
            Log.d(TAG, "point1: x=" + event.getX(0) + ", y=" + event.getX(0));
            Log.d(TAG, "point2: x=" + event.getX(1) + ", y=" + event.getX(1));
            Log.d(TAG, "point3: x=" + event.getX(2) + ", y=" + event.getX(2));
            break;
        case MotionEvent.ACTION_UP:

            break;
        default:
            break;
    }

    return true;
}

 

posted @ 2015-08-24 21:53  carlo-z  阅读(350)  评论(0编辑  收藏  举报