Note that there are some explanatory texts on larger screens.

plurals
  1. POSet Spark Element's maxHeight to 100% of Container's
    primarykey
    data
    text
    <p>I have a list component with a (row oriented) tile layout in a group that sits in the main Application.</p> <p>I want the list to be centred vertically when there are not enough items in to fill the application window height, so verticalCenter="0".</p> <p>However, when there are more items than can fit vertically on screen, the list expands beyond the application window height and the scrollbar doesn't kick in. </p> <p>I can remedy this if setting the list height to 100%, but that means it's not vertically centred when it contains less items.</p> <p>The ideal solution would be maxHeight="100%", but of course maxHeight doesn't work with percentages. How would I go about achieving this behaviour?</p> <p>Thanks,</p> <p>Tim</p> <p><strong>Edit: Please see the code below:</strong></p> <pre><code>&lt;s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="applicationCompleteHandler(event)" width="800" height="600" showStatusBar="false"&gt; &lt;fx:Script&gt; &lt;![CDATA[ import mx.collections.ArrayList; import mx.events.FlexEvent; protected function applicationCompleteHandler(event:FlexEvent):void { var arrayList:ArrayList = new ArrayList; for (var i:int = 1; i &lt;= 50; i ++) { arrayList.addItem(String(i)); } list.dataProvider = arrayList; } ]]&gt; &lt;/fx:Script&gt; &lt;s:List id="list" itemRenderer="itemRenderer" useVirtualLayout="false" horizontalCenter="0" verticalCenter="0" borderVisible="false"&gt; &lt;s:layout&gt; &lt;s:TileLayout orientation="rows" requestedColumnCount="4" columnWidth="150" rowHeight="150"/&gt; &lt;/s:layout&gt; &lt;/s:List&gt; &lt;/s:WindowedApplication&gt; </code></pre> <p>This is my item renderer:</p> <pre><code>&lt;s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" autoDrawBackground="true"&gt; &lt;s:Rect width="100%" height="100%"&gt; &lt;s:stroke&gt; &lt;s:SolidColorStroke color="0"/&gt; &lt;/s:stroke&gt; &lt;/s:Rect&gt; &lt;s:Label text="{data}" horizontalCenter="0" verticalCenter="0" fontSize="50"/&gt; &lt;/s:ItemRenderer&gt; </code></pre> <p>If the for loop is changed to only 10 iterations, the list is centred vertically on the screen. Otherwise the list expands beyond the screen, centred vertically and no scrollbar appears.</p> <p>Using clipAndEnableScrolling hasn't made any difference. I've also tried putting the list inside a group with 100% width &amp; height, but I'm getting more or less the same behaviour except the list is flush to the top when it is taller than the container. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload