How to set a Spark List height to the height of its content?
Tried this:
var lastRow:IVisualElement =
myList.dataGroup.getElementAt(myList.dataGroup.numElements - 1);
myList.height = lastRow.y + lastRow.height;
It works in case of a single item, but lastRow is null in case of more items.
In mxml you can do it like so:
<s:List width="100%">
<s:layout>
<s:VerticalLayout useVirtualLayout="false" requestedMinRowCount="1"/>
</s:layout>
</s:List>
You set the requestedMinRowCount or the requestedRowCount in the layout inside the List. It got me before, too. Hope that helps.
For TileList I did it like this:
<s:List width="100%" height="{(tilelayout.rowCount * tilelayout.rowHeight) + ((tilelayout.rowCount - 1) * tilelayout.verticalGap)}">
<s:layout>
<s:TileLayout id="tilelayout" rowHeight="190" columnWidth="130" horizontalGap="5" verticalGap="10" />
</s:layout>
</s:List>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With