Android 多点触控
因此,我尝试使用 onTouchEvent 检查多个屏幕触摸,但它似乎仍然只读取第一次触摸。有人可以帮忙吗? 这是我的代码:
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));
check(x,y);
}
return false;
}
我浏览了很多此类论坛,但大多数与多点触控相关的主题都是关于缩放的。
So, I am trying to check multiple screen touches with an onTouchEvent, but it still only seems to read the first touch. Can anyone help?
Here is my 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));
check(x,y);
}
return false;
}
I looked over a lot of these forums, but most of the multi touch related topics were about zooming.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码在我的设备(Nexus S、Android 2.3)上运行良好。它读取所有触摸。
这是测试代码:
这是日志(用 5 个手指触摸):
您的 Android 设备和操作系统版本是什么?
Your code works well on my device (Nexus S, Android 2.3). It reads all touches.
Here is the test code:
Here is the log (touch with 5 fingers):
What is your Android device and OS version?
发生这种情况是因为当您想要移动时,您的方法将
返回 false
。所有多指操作都应返回 true
。This happens because your method will
return false
when you want to make move. All multi finger actions shouldreturn true
.