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;
}
上一篇:资源: StaticResource, ThemeResource


下一篇:从零开始学Python08作业思路:开发简单的FTP