According to 
http://developer.android.com/guide/topics/ui/custom-components.html:

onMeasure(int, int)     Called to determine the size requirements for this
view and all of its children.
onLayout(boolean, int, int, int, int)   Called when this view should
assign a size and position to all of its children.

RelativeLayout doesn't do this; it actually assigns a size and
position to all of its children in onMeasure.  From the source code of
RelativeLayout:
    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int
b) {
        //  The layout has actually already been performed and the
positions
        //  cached.  Apply the cached values to the children.

This is bad because, I wanted to override a RelativeLayout and assign
it a specific height.  However, the children of this RelativeLayout
would not respect the height I assigned, because the children assign
themselves positions and sizes in onMeasure.  And therefore the
children don't fit in the RelativeLayout.

IMHO it's a bad sign of the design when the actual framework doesn't
follow its own design.  I know this sounds like a flame or a rant, but
I'm just trying to point out what I believe to be a underlying problem
here.  If you can't override a RelativeLayout then it should have been
declared final (but that's too drastic).  Perhaps the onMeasure and
onLayout need to be rethought (guess it's too late for that :).  At
the very least, the documentation should be updated so that one knows
that when subclassing RelativeLayout, that the size and position of
all of its children are actually assigned in onMeasure and onLayout.


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