Interestingly I've noticed that even if you *do* subclass the layout manager (or any view on which setContentView is called) and implement onSizeChanged(), the first onSizeChanged after an orientation change will contain the old width/height, then it will immediately get another onSizeChanged with the correct width/height.
I wrote up a simple test case and further explanation on Stack Overflow here: http://stackoverflow.com/q/9696118/369658 Any idea why this happens? thanks, -mike On Thursday, August 25, 2011 11:02:07 AM UTC-7, Dianne Hackborn wrote: > > You can do this yourself by just say subclassing a FrameLayout (or the > layout manager of your choice) and calling out. > > I really recommend implementing your own layout manager for this kind of > stuff, though, because it is important to fully participate in the layout > when you want UI elements to visually cooperate together. > > On Thu, Aug 25, 2011 at 10:44 AM, Doug <beafd...@gmail.com> wrote: > >> On Aug 23, 10:05 am, Dianne Hackborn <hack...@android.com> wrote: >> > You need to participate in the view hierarchy as a layout manager, do >> get >> > the onSizeChanged() calls and such. >> >> Since it's come up, it's actually been a thorn in my side to have to >> "be" a layout manager to know something simple such as the size of a >> view when it's changed size. It comes up again and again for some >> things I do. It would be a huge save of time and effort if I could >> just register a listener on a View to know when its onSizeChanged >> method has been called. >> >> For example, if I want to place an overlay on some arbitrary view as a >> callout or popup, I need to know its size and position the moment >> those things are known. I can't do it during any of the activity >> lifecycle methods because layout is a different stream of computation >> than the lifecycle. Same thing goes if I need to compute coordinates >> for an animation that happens at activity startup rather than on UI >> events. >> >> I've seen people hack up ugly polling looping to find out when layout >> completes! And it seems like huge waste of time just to implement a >> custom View or LayoutManager just to make this work. I hope that I'm >> just going about this the wrong way and that there is a more elegant >> solution. In the absence of that, having a hook into a view's >> onSizeChanged would be a huge win, IMO. >> >> Doug >> >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to android-developers@googlegroups.com >> To unsubscribe from this group, send email to >> android-developers+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en