Android 3手指触摸检测
我使用以下代码成功地记录了在屏幕上触摸的两个手指的坐标:
case MotionEvent.ACTION_MOVE:
Log.d("TOUCH", "test ACTION MOVE" + event.getPointerCount());
Log.d("TOUCH", "test ACTION MOVE ID" + event.getPointerId(0) + " "+event.getPointerId(1));
if(event.getPointerCount()==3)
{
x0 = (int) event.getX(event.getPointerId(0));
y0 = (int) event.getY(event.getPointerId(0));
x1 = (int) event.getX(event.getPointerId(1));
y1 = (int) event.getY(event.getPointerId(1));
x2 = (int) event.getX(event.getPointerId(2));
y2 = (int) event.getY(event.getPointerId(2));
Log.d("TOUCH", "test ACTION DOWN " + " values = " + x0 + " " + y0 + " "
+ x1 + " " + y1+ " "+x2 + " " + y2);
}
但是在上面的代码中,我无法在单个实例中检测到两个以上的触摸点。即使pointerCount()也永远不会超过2。
我怎样才能获得超过2个手指的触摸坐标?我在 Android 2.2 上运行此代码
I am successfully able to record the coordinates of the two fingers being touched on the screen using the following code:
case MotionEvent.ACTION_MOVE:
Log.d("TOUCH", "test ACTION MOVE" + event.getPointerCount());
Log.d("TOUCH", "test ACTION MOVE ID" + event.getPointerId(0) + " "+event.getPointerId(1));
if(event.getPointerCount()==3)
{
x0 = (int) event.getX(event.getPointerId(0));
y0 = (int) event.getY(event.getPointerId(0));
x1 = (int) event.getX(event.getPointerId(1));
y1 = (int) event.getY(event.getPointerId(1));
x2 = (int) event.getX(event.getPointerId(2));
y2 = (int) event.getY(event.getPointerId(2));
Log.d("TOUCH", "test ACTION DOWN " + " values = " + x0 + " " + y0 + " "
+ x1 + " " + y1+ " "+x2 + " " + y2);
}
But In the above code im not able to detect more then 2 touch points at a single instance. Even the pointerCount() never goes above 2.
How can I get the touch coordinates for more then 2 fingers? Im running this code on Android 2.2
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
前段时间有人问过这个问题,但无论如何。答案是,虽然 Android 可以跟踪 256 个手指,但当前的实现将其限制为 2 个手指。
我不确定蜂窝,但我猜它有同样的“问题”。
This was asked some time ago, but anyway. The answer is that although android could track 256 fingers, the current implementation limits this to 2 fingers.
I'm not sure about honeycomb, but I guess that it has the same "issue".
我已经在一些 Android 2.3.5 设备以及我迄今为止测试过的所有 3.x 和 4.x 设备上确认了 4 次触摸。看来至少从 API 8+ 开始,支持两次以上触摸,但它依赖于设备。
I've confirmed 4 touches on some Android 2.3.5 devices, and every 3.x and 4.x device I've tested so far. It seems that at least from API 8+, more than two touches is supported, but it's device-dependent.
使用两个以上手指的多点触控只能在 android 4.1.2 版本或更高版本中执行,并且不同的公司根据自己的需求和应用程序定制了 android 版本,即在 4.1.2 版本中,Qmobile 仅支持五个手指,但伟大的三星公司使用超过11根手指
multitouch which uses more than two fingers can only be performed in android 4.1.2 version or above and also different companies have customized the android versions according to their needs and apps i.e in 4.1.2 version the Qmobile just support five fingures but the great samsung company uses more than 11 fingers