How to find the coordinates of the top of the View

Put your problem here if it does not fit any of the other categories.

How to find the coordinates of the top of the View

Postby prepbgg » Thu Jan 07, 2010 12:20 pm

I have a program with a single View filling the screen under the notification bar and the app's title bar.

get(Height) correctly tells me the height in pixels of the View;
getY() applied to a MotionEvent gives the distance in pixels from the top of the screen.

I know that in the emulator and in my current device the top of the view is 50 pixels from the top of the screen so I can subtract 50 from getY() to determine the Y coordinate relative to the top of the View.

However, presumably I can't rely on this difference always being 50, so how can I programmatically deterrmine the coordinates of the top (and left) of the View?
prepbgg
Freshman
Freshman
 
Posts: 5
Joined: Tue Jan 05, 2010 4:53 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests