U.P
U.P

Reputation: 7442

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?

Upvotes: 1

Views: 3664

Answers (1)

aptwebapps
aptwebapps

Reputation: 1876

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.

Upvotes: 3

Related Questions