Guys, I was under the impression that measured dimensions were "suggestions" that could be overridden at the time drawing occurs. Therefore, overriding those classes would allow for additional information to be given to Android, but at draw time, you would need to getWidth and getHeight in order to know that your measurements in onMeasure were actually used.
Therefore, to solve the problem that way, you would need to capture all elements on the screen and get their measurements to know that your suggested measurements would actually be used for the screen that is displaying it. That seems like a lot of work to me and it would be easier to wait until everything is displayed, then get your layout params so you can then pack it with the views you want according to the actual, drawn size. That's all I was saying... Overriding onSizeChanged is a very good point, though, in the event that a View changes size and Android redraws and changes the size of the View of interest. -Jim On Aug 6, 2:00 pm, Kostya Vasilyev <kmans...@gmail.com> wrote: > Sure. I'd start here: > > http://developer.android.com/guide/topics/ui/custom-components.html > > The layout process involves these three onXXX overrides, as listed in > the table halfway down the page: > > ||onMeasure(int, int) > ||||||onLayout(boolean, int, int, int, int) > ||||onSizeChanged(int, int, int, int) > > There is documentation for each of these three methods, as well, such as: > > http://developer.android.com/reference/android/view/View.html#onSizeC..., > int, int, int) > > -- Kostya > > 06.08.2011 22:54, Matt Tatro пишет: > > > > > > > > > > > Kostya, > > Any example I could follow? > > > Kind Regards, > > > Matt Tatro > > T: +1 (281) 905-1008 > > E: mattta...@gmail.com > > > -----Original Message----- > > From: android-developers@googlegroups.com > > [mailto:android-developers@googlegroups.com] On Behalf Of Kostya Vasilyev > > Sent: Saturday, August 06, 2011 11:51 AM > > To: android-developers@googlegroups.com > > Subject: Re: [android-developers] Re: Is there a callback that gets called > > right after onResume() ? > > > Or one could use the tools already provided by the framework ... > > > ... by subclassing a xxxLayout class or a ViewGroup and overriding > > onMeasure and onLayout ... > > > ... or by subclassing the appropriate view and overriding onSizeChanged ... > > > -- Kostya > > > 06.08.2011 20:42, Jim пишет: > >> There is no callback - you can set flags in onResume() to know when > >> the activity is done with that part of the lifecycle. However, by > >> using layout_weight, you're telling Android to decide the size, which > >> it can't know until the screen is drawn, so a callback to change the > >> size won't work without a Handler to request a redraw or cycling > >> through onPause/onResume. So, you're going to need a Handler, which is > >> effectively a hack (to avoid layout_weight, you can get screen and > >> view dimensions and other data during onCreate/onStart/onResume to > >> calculate the available screen space yourself, determine which > >> elements will show and then calculate/recalculate certain element > >> sizes to get what you want, but that's a lot of work - a hack is > >> probably a better approach for this type of job). > > >> If you want to determine the available size, then start a background > >> thread/timer at the end of onResume(), when you know how much space > >> you have for your elements, do the size calculations, then > >> runOnUIThread the changes and you should be fine. If you want to > >> guarantee the user does not see the changes, you're going to have to > >> work harder since the background thread/timer is not synchronized with > >> the UI. > > >> -Jim > > >> On Aug 6, 2:58 am, Zsombor<scythe...@gmail.com> wrote: > >>> Is there a callback that gets a call when everything in the current > >>> Activity got rendered? > > >>> Because I need to know the exact sizes of some of my ViewGroups > >>> (their width/height are set using layout_weight in the layout xml), > >>> so I know how many elements fit inside them without scrolling. But I > >>> can only measure them after onResume. Is there a way to do this > >>> without some hack? > > -- > > Kostya Vasilyev > > > -- > > 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 > > -- > Kostya Vasilyev -- 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