Hi, I have a FrameLayout in my Activity of which I need to know the size in pixels at runtime. Although getWidth() and getHeigh() return 0 for any(?) ViewGroup without any children, I figured out that I can use the functions getMeasuredWidth() and getMeasuredHeight() to get the actual size on screen after the FrameLayout has become visible.
As far as I know there is no Activity callback that gets called after everything in the Activity (including the FrameLayout) is visible to the user. Before that point in time however, getMeasuredWidth() and getMeasuredHeight() also return 0. I am wondering that the preferred way of getting the size of that view at runtime are. I came up with two possible solutions: Overwriting onWindowFocusChanged() in the Activity: this is a default Android callback that not only gets called after the Activity is visible but also after anything else has taken the focus. It seems to get me where I want but it seems not very elegant. Another option would be to make my Activity implement a custom interface called OnSizeChangedListener, then overwrite the onSizeChanged of the FrameLayout to notify the OnSizeChangedListener of any changes in size. This seems to only get called when the window size actually changes. However, I am a bit unsure if it is good practice to implement a new listener for this. What approach would you suggest? Thanks, Philipp -- 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

