How do i get the point/coordinate the user clicked on an android view?

两盒软妹~` 提交于 2019-12-09 03:09:33

问题


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

Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/3657243/how-do-i-get-the-point-coordinate-the-user-clicked-on-an-android-view

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