我如何获得的x,y坐标为屏幕触摸? [英] How do i get the x,y coordinate for a screen touch?

查看:218
本文介绍了我如何获得的x,y坐标为屏幕触摸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法来获得X,Y坐标,而我的应用程序运行时,每当有人触摸屏?只是寻找将它们存储在一些整数。

Is there a simple way to obtain the x,y coordinate whenever someone touches the screen while my app is running? Just looking to store them in some integers.

推荐答案

覆盖的onTouchEvent(MotionEvent事件),然后调用 event.getX() event.getY()来获得的,其中用户触摸的坐标位置[他们会花车。

Override onTouchEvent(MotionEvent event) and then call event.getX() and event.getY() to get the coordinate positions of where the user touched [they will be floats].

这篇关于我如何获得的x,y坐标为屏幕触摸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆