There are at least two passes made for laying out views, and my custom view has onMeasure and onLayout overrides. At the end of onMeasure I call setMeasuredDimension as required by the API, and then onLayout usually gets called next. What I have noticed is that if, on the 2nd pass, I call setMeasuredDimension with the same arguments as the first time, then my onLayout is not called the 2nd time.

This was causing a bug in my app since I have several child views that I need to size and rearrange within this parent container view. But since what I am doing is to fit the child views into the visible space on the screen, the "measured dimension" of the container view may not change from one pass to the other, and the children don't get re-layed out (the layout parameters from the 1st pass are not the final values).

I currently have a kludged workaround for this, but I'm wondering if it would be OK to call layout() on my child views from within onDraw instead of within onLayout. The parent view does get drawn first, so I would guess that this wouldn't hurt anything.

Doug Gordon
GHCS Software

--
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

Reply via email to