I have searched alot of this issue on google but unable to get any help.My question is how to get pixel position of android screen where the user has tapped?
Asked
Active
Viewed 599 times
0
3 Answers
3
this does the job.
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();

Vinay W
- 9,912
- 8
- 41
- 47
-
Thanks, my onTouchEvent() not get called whenever I run my application. Are there any Listeners thats need to be setup? – muneikh Jul 11 '12 at 06:39
-
don't think so, see [this](http://android-coding.blogspot.in/2011/05/handle-ontouchevent-in-surfaceview.html) – Vinay W Jul 11 '12 at 06:44
1
This is probably what you're looking for: onTouchEvent

Paresh Mayani
- 127,700
- 71
- 241
- 295

Brad
- 9,113
- 10
- 44
- 68
0
-
-
2`getRawX()` gives x-coordinate of event on screen, and `getX()` gives x-coordinate of event on view. So, `getX()` may be negative, if you move finger to left of your view. – Jin35 Jul 11 '12 at 07:13