Its possible that your view hasn't been drawn yet. An important thing
to remember though is that getTop() returns an offset value relative
to the views parent. This means that regardless of where your parent
is on screen, if your view is positioned at the top of the parent
view, getTop() will return 0.

To get your windows absolute position on screen, call,
getAbsoluteLocationOnScreen(int []).

Cheers,
Justin
Android Team @ Google

On May 8, 10:23 am, [EMAIL PROTECTED] wrote:
> > I'm declaring some view inside my layout xml file and then I'm trying
> > to figure out their location with getTop(), bottom, right, left etc.
> > However, the end result is that it always returns 0, why is this?
>
> It's just a guess, but...
>
> It may be that the view hasn't been measured and drawn yet (e.g., occurs
> after onCreate() returns), so the widgets don't know their position. To
> test this theory, try logging their values at some later point (e.g.,
> onResume()) and see if they're non-zero. At least, the ones you expect to
> be non-zero (e.g., getTop()).
>
> --
> Mark Murphy (a Commons Guy)http://commonsware.com
> The Busy Coder's Guide to Android Development -- coming in June 2008!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to