Coordinates in MotionEvent are *not* absolute. MotionEvent.getX() and MotionEvent.getY() return the location in the coordinate space that the event has been dispatched to.
If you are getting these somewhere outside of a view (such as Activity.onMotionEvent()) they will probably be relative to the window. They will never be relative to the screen. MotionEvent.getRawX/Y() return the coordinates in the screen space. If you are in a situation where you are getting coordinates relative to the window but actually want them relative to some other UI element, you are probably getting them from the wrong place. On Wed, Apr 13, 2011 at 6:09 PM, gjs <[email protected]> wrote: > Hi, > > Touchscreen co-ordinates seem to be absolute device/screen > coordinates, so you need to account for this offset for your app > screens when status bar is present. > > Be careful though are status bar is not always present, it can be > different heights for different Android versions/devices & on Android > 3.0+ devices is at bottom of screen rather than top of screen. > > I'd also be interested to know how others handle this effectively & > generically given the variables mentioned. > > Regards > > On Apr 13, 11:50 pm, henry <[email protected]> wrote: > > When I develop a app, I click at the up-left corner, I got x=0 y=59 or > > something. How do I determine the y value? There are two rows above my > > Touchable screen in my app: > > 1 first line/row is a tool/status bar which I don't know how to access > > it > > 2. next line is my app name like "Hello World". > > I think this two play a role to determine the y value. > > How do I termine origin y value in my program? > > > > -Henry > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

