2 Replies Latest reply on Jul 31, 2009 9:05 AM by dragonmagik

    Restore Container's height

    oscar7878 Level 1

      Hi,

       

      When you have a container, like a Canvas or HBox,  and you haven't modifed its height, you can add as many children to it and it height will adjust automatically. Once you modify its height, let's say to 150, if the children need more vertical space, the container shows a vertical scroll bar.

       

      My question is how I can restore the container to its default properties (specially height) after I change it's height at tun time. The percentHeight doesn;t work because it uses the max height available. I want the conainer to use all the vertical space it needs (to hold its children) without scroll bars even if that means that the application container has a scroll bar. In other words I'm looking for something like <HBox resizeToContent="true">

       

      Thanks in advance.

        • 1. Re: Restore Container's height
          Flex harUI Adobe Employee

          percentHeight should cause it to re-measure all the children.  Note that, if you set the height to 150 by setting height=150, it resets percentHeight to NaN so you have to reset percentHeight=100.

           

          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui

          • 2. Re: Restore Container's height
            dragonmagik

            Default behavior for a container is to measure the required width / height based on children, styles (font size, spacing, padding, etc) layout, etc.

             

            This is done in UiComponent.measure() method.

             

            this method sets four proeprties, measuredWidth, measuredHeight, measuredMinWidth, measuredMinHeight.

             

            If you have set any sizing propety, width, height, explicitWidth, explicitHeight, percentWidth, or percentHeight the UiComponent no longer calls the measure method.  it would be redundant, it wouldn't use measuredWidth/height anymore, but the user set size.  If you have explicitly set a width or height (percent included) then you need to unset it to get the component to measure itself again.  Set the property to NaN to effect this behavior.