If you have two rectangles side-by-side, and one is not in the layout, the
container's width is going to be the one in the layout. In most cases,
folks do not want the container to reserve room for the one not included.
If you want the container to reserve room, then just set visible=false, not
But if you don't want to reserve room, then you really aren't asking for
width, and will have to compute it yourself.
Yeah, unfortunately that does not really help me.
The idea is that I want to know what the potential width of a component would be, if I apply a certain value to a certain property. Knowing the consequences of applying that value, before I actually apply it, helps me keep my layout dynamic.
I suppose it is just not possible however.
It is totally possible, but not by reading the width property. You can try
temporarily setting includeInLayout, calling validateNow and checking
measuredWidth and setting includeInLayout again, or just get the children
and loop through them summing their measuredWidths.
Yeah, that is basically what I had come up with.
Initially, before making UI visible to user, I will take note of the different cases and their potential sizes.
Side note : What's the easy explanation for measuredWidth vs width?
Thanks for the help.
MeasuredWidth is the width of the content it will layout. Width is the size
it is actually layed out as.
If I had a Button with a label and set the width to 100%, the button's
measuredWidth will be the size of the label plus some margin, but the final
button width can be much different because it is sized to the parent's