Issue
I've got a mapview that I want to put some markers on top of. I'll retrieve these from a webservice when I start the activity, so I need to know the minimum and maximum lat/lng pairs for the current viewport. I'm calling
mMapView.getWidth()
mMapView.getHeight()
But they both return 0 while the activity is starting. I tried putting it in onAttachedToWindow, onResume, onPostCreate, onPostResume, onStart and so on, but to no avail. How can I know that the activity has finished laying out all the views and is ready to give me the correct height and width measurements?
Solution
I think you have to override onSizeChanged and call getWidth/Height from there. Be aware though that onSizeChanged might get called multiple times during your activity's lifecycle (Everytime the size of the view changes).
Answered By - Julien
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.