Android Multi Touch

荒凉一梦 提交于 2019-12-06 04:18:24

Your code works well on my device (Nexus S, Android 2.3). It reads all touches.

Here is the test code:

  public boolean onTouchEvent(MotionEvent e) {
    int num = e.getPointerCount();
    for (int a = 0; a < num; a++) {
      int x = (int) e.getX(e.getPointerId(a));
      int y = (int) e.getY(e.getPointerId(a));
      Log.d(TAG, "pointer_" + e.getPointerId(a) + ": x = " + x
          + ", y = " + y);
    }
    return false;
  }

Here is the log (touch with 5 fingers):

11-09 17:32:55.542: D/Touch(20594): pointer_0: x = 169, y = 613
11-09 17:32:55.542: D/Touch(20594): pointer_1: x = 407, y = 289
11-09 17:32:55.542: D/Touch(20594): pointer_2: x = 62, y = 441
11-09 17:32:55.542: D/Touch(20594): pointer_3: x = 251, y = 202
11-09 17:32:55.542: D/Touch(20594): pointer_4: x = 132, y = 256

What is your Android device and OS version?

ignacio pugliese

This happens because your method will return false when you want to make move. All multi finger actions should return true.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!