How to get double touch position in android?

空扰寡人 提交于 2019-12-09 01:52:35

问题


I need to get the positions of each touch when a double touch has done I know that you can get the position of one touch with:

int x = (int)event.getX();
int y = (int)event.getY();

how can I get a second x and y?


回答1:


event.getPointerCount() will tell you how many touch points there are. To get the other ones, just use an index value in the "Get" method:

x0 = event.getX(0);
x1 = event.getX(1);
...




回答2:


Why dont you use a logic inside an onTouch function. Use static variable and keep a count if cout becomes two, it's a double click.



来源:https://stackoverflow.com/questions/8681582/how-to-get-double-touch-position-in-android

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