我如何获得点/坐标用户点击一个机器人有何看法? [英] How do i get the point/coordinate the user clicked on an android view?

查看:120
本文介绍了我如何获得点/坐标用户点击一个机器人有何看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ImageView的和点击时,调用 OnClickListener.onClick(视图v)。我如何得到确切点/坐标,用户点击?

I have an imageview and when clicked, calls OnClickListener.onClick(View v). How do I get the exact point/coordinate that the user clicked?

感谢

推荐答案

您不能得到协调OnClickListerner感动。 请使用,而不是它OnTouchListener.onTouch(视图V,MotionEvent事件), 并且你可以从该事件的坐标。

You can't get the coordinate touched in OnClickListerner. Please use OnTouchListener.onTouch(View v, MotionEvent event) instead of it, and you could get the coordinate from the event.

这篇关于我如何获得点/坐标用户点击一个机器人有何看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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