simple flex layout problem

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default simple flex layout problem

    I have what I would expect to be a very simple layout, but can't get it to
    behave the way I thought it should.

    Basically, my application is set to 100% width and height. Within that, I have
    an HDividedBox with 80% width and height. Within that, I have 2 VBoxes in which
    the content is dynamic and can grow to any size. The problem is that my inner
    VBoxes push the HDividedBox larger than 80% of the Application resulting in the
    application showing scrollbars instead of the inner VBoxes. All I want is for
    the HDividedBox to remain 80% of the Application (browser window) and for the
    inner VBoxes to do their own scrolling if needed. My code is attached.

    Thanks

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
    height="100%" width="100%">
    <mx:HDividedBox height="80%" width="80%">
    <mx:VBox height="100%" width="80%" borderStyle="solid">
    <mx:Panel height="1500" width="400">
    <mx:Text width="100%" text="This panel is set to taller than the inner
    left VBox, and I want the VBox to scroll instead of the application"/>
    </mx:Panel>
    </mx:VBox>
    <mx:VBox height="100%" width="20%" borderStyle="solid">
    <mx:Panel >
    <mx:Label text="This panel is small"/>
    </mx:Panel>
    </mx:VBox>
    </mx:HDividedBox>
    </mx:Application>

    ssettl2 Guest

  2. Similar Questions and Discussions

    1. Help loading .net webservice data into flex grid -surely this is simple???!!!
      Hi, Tanks for your answer, but im not seem the solution yet. I have dificult whith XML structure. My webservice return the XLM below. I need...
    2. flex builder does not render layout controls
      Hi to everyone, I've a little problem with Flex Builder When I place in the Flex Builder Design Area any Layout Control (Panel, VBox,...
    3. Simple Questions from Flex Newbie about Links and Lists
      Hi, I am working on creating a little flex app that my users can embed into any other sites of their choice. I want to start out by creating a...
    4. About Creating a Simple Calculator with Macromedia Flex
      Hi, In Creating a Simple Calculator with Macromedia Flex Article, I have seen that the author assign the (currentRegister variable) with (reg1...
    5. simple layout question
      i'm trying to build a page that will centralise in both 1024 x 768 & 800 x 600 browser windows. so the page will fill almost the full screen of the...
  3. #2

    Default Re: simple flex layout problem

    The short answer is that what is happening is supposed to happen - it is not a
    bug. Personally, I think this is not the way it should work, but that's just my
    opinion. Here's what's happening:

    The Box containers are designed to grow to accomodate their children. If you
    have an HBox, each time you add a child component the HBox gets bigger. Makes
    sense, right? You can position the HBox within its parent using x and y
    properties or the top and left styles.

    Here's where it gets weird for me. If you use percentage sizes such as
    width="100%" on the HBox, this is merely a guide to how large it is. The HBox
    will continue to expand to show all of its children. When it's parent gets a
    report of the HBox size that it has exceeded its boundaries, the parent will
    either a) also grow larger or b) put up scrollbars - on itself, not on the HBox.

    It is the (a) case you are facing. You've used percentage sizing and so the
    containers are all expanding to fit their children.

    The solution is to set the width and/or height to absolute values. If you give
    the HBox a width="600" and you add children such that it gets larger than 600
    pixels, the HBox won't expand, it will show a scrollbar.

    First, set the HDividedBox's width to be {width*.8} which will be 80% of the
    Application's width. Then set its children's height and width values to be
    calculations as well: height="{hdivbox.height*.8}" width="{hdivbox.width}"
    where hdivbox is the id of the HDividedBox.

    I can live with the behavior for percentages, but what I find frustrating is
    that the right and bottom constraint styles have no effect either. To me,
    setting top="5" and bottom="5" on a VBox should establish a calculated height.
    But it does not. It acts like the height="90%".

    You'll have to play with the calculations a bit, but that's the only way this
    will layout properly in my experience. Please file an enhancement request at
    [url]http://bugs.adobe.com[/url] if you feel strongly about the way this behaves.



    peterent Guest

  4. #3

    Default Re: simple flex layout problem

    Hi.

    If you haven't already made your changes according to what I said, there may
    be a simpler way to do this:

    On those containers you want to have the scrollbars, ADD minHeight="0" or
    minWidth="0" (depending on where you want the scrollbars).

    It turns out, the reason the scrollbars propagate to the Application is that
    by default, the containers do not want to get smaller than their measured size.
    By setting minWidth or minHeight to 0 (zero), you tell the Flex framework that
    it is OK for the containers to be smaller than their children and thus, get
    their own scrollbars.

    Give that a try.

    peterent Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139