tags:

views:

48

answers:

1

I have this element in my layout XML:

<FrameLayout android:id="@+id/FrameLayout01"
 android:layout_width="320sp" android:layout_height="380sp"
 android:layout_gravity="center" android:background="#99CC33">
</FrameLayout>

And I want to get its position on the screen with getTop(), getBottom(),... but I want to do it only once. I was trying to do it on the onCreate(), but those methods return all 0 as response.

Any tips?

A: 

The problem is that the screen isn't created before the onCreate. For example I used to try and get the screen height and width in the onCreate but it doesn't work because it's not set up yet. To solve the problem I used a custom View and overrode the function onSizeChanged.

Chris L.
Well... that's an answer... but i'll need to pass a callback to my other class, and it will be called just one time...
Eduardo Aquiles