简体   繁体   中英

How to get x y position where user has touched on screen in android?

Hi I want to get x and y position of screen where the user has touched. How can I do that?

It depends a little on the way you're doing your view. Usually you attach an event listener to your view in your onCreate() method. More here

If you have a custom view then you might use a handler instead, which means you override the onTouch() method in your view.

Either way you'll get an event object which has the x and y values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM