Flex 4: Setting Spark List height to its content height

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.

flex flex4

share|improve this question

asked Apr 1 '10 at 9:34

alexey

2,83832553

add comment

5 Answers

active oldest votes

up vote 20 down vote accepted

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.

share|improve this answer

answered Sep 29 '10 at 22:17

Marty

21633

I'm trying to get this to work with TileLayout, but there is no requestedMinRowCount for TileLayout. I wonder how to get the height to dynamically set for the list when using TileLayout so that the list only takes up space for which it needs to display it's rows? –  Stephen Horvath Aug 30 '11 at 18:03

add comment

up vote 2 down vote

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>

share|improve this answer

edited Aug 31 '11 at 0:40

answered Aug 30 '11 at 18:14

Stephen Horvath

1138

add comment

up vote 2 down vote

try this layout - for regular list

<s:layout>
<s:VerticalLayout horizontalAlign="contentJustify"
gap="0"
verticalAlign="middle"
variableRowHeight="false"/>
</s:layout>

share|improve this answer

answered Nov 22 '11 at 11:35

Amalia

211

add comment

up vote 0 down vote

public class MyTileLayout extends TileLayout
{ override public function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w,h); target.height = rowCount*rowHeight + verticalGap*(rowCount - 1);
} }

Or you can extend your TileLayout :)

share|improve this answer

answered Nov 4 '11 at 15:08

Katya

1

add comment

up vote 0 down vote

Easiest way to do this

height="{list.dataGroup.contentHeight}"

share|improve this answer

关于flex4 list 高度适应内容的更多相关文章

  1. 实现textarea高度自适应内容,无滚动条

    最近接触到一个很好用的js插件,可以实现textarea高度随内容增多而改变,并且不显示滚动条,推荐给大家: http://www.jacklmoore.com/autosize/

  2. iframe高度自适应内容

    JS自适应高度,其实就是设置iframe的高度,使其等于内嵌网页的高度,从而看不出来滚动条和嵌套痕迹.对于用户体验和网站美观起着重要作用. 如果内容是固定的,那么我们可以通过CSS来给它直接定义一个高 ...

  3. Textarea高度随内容自适应地增长,无滚动条

    <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; char ...

  4. 限制div高度当内容多了溢出时显示滚动条

    <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type"content= ...

  5. textarea高度随内容自适应

    最近遇到一个需求,视频名称初始有个生成值,并且支持可以手动修改,修改后名称过长后换行高度随内容增加.刚开始想到用input但是发现input不支持换行.后来用了textarea,用js来控制,下面是实 ...

  6. textarea的高度随内容变化而变化

    <li class="text"> <span>参赛宣言*</span> <textarea name="txt" i ...

  7. 如何使tinymce编辑器的高度随内容自变化(转载)

    如何使tinymce编辑器的高度随内容自变化 最简单的方法就是在配置时添加Autoresize插件: tinymce.init({ selector: "textarea", // ...

  8. textarea文本域的高度随内容的变化而变化

    用css控制textarea文本域的高度随内容的变化而变化,不出现滚动条. CSS代码: 复制代码 代码如下: .t_area{ width:300px; overflow-y:visible } & ...

  9. textarea高度随着内容的多少而变化,高度可以删减

    问题:可以多行输入,并且输入框的高度随着内容的多少而变化,输入框的高度不能只增不减 由于 input 只能单行输入 textarea可以多行输入,并且高度可以随着内容的增加而增加,但是当内容删减的时候 ...

随机推荐

  1. UTF8,UTF16,UTF32,UTF16-LE,UTF16-BE,GBK 之间的转换

    Unicode是Unicode.org制定的编码标准,目前得到了绝大部分操作系统和编程语言的支持.Unicode.org官方对Unicode的定义是:Unicode provides a unique ...

  2. hdu_4826_Labyrinth_2014百度之星(dp)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 题意:中文题,不解释 题解:dp搞,第一列只能从上往下走,所以先算出第一列的dp数组,然后开两个 ...

  3. Git 多人协作开发

    当你从远程仓库克隆时,实际上Git自动把本地的master分支和远程的master分支对应起来了,并且你的远程仓库的默认名称是origin 查看远程库的信息,用git remote LV@LV-PC ...

  4. ios 视频播放

    #import "ViewController.h"@import MediaPlayer; @interface ViewController (){    MPMoviePla ...

  5. javascript操作json

    for (var i = 0; i < selectedPartList.length; i++) { if (selectedPartList[i].vpart_code == jsonRow ...

  6. 【转】虚拟机下安装小红帽Linux9.0图解

    http://blog.163.com/ly676830315@126/blog/static/10173372220119148583539/

  7. Activity竟然有两个onCreate方法,可别用错了

    public class HomeDetailActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceSt ...

  8. 《Head.First设计模式》的学习笔记(9)--外观模式

    意图:为子系统中的一组接口提供一个一致的界面,Facade 模式定义了一个高层接口,这个接口使得这一子系统更加容易使用. 结构: 例子: 假设你有一套杀手级的家庭影院系统,内含DVD播放器.投影仪.自 ...

  9. 实参时丢弃了类型 discards qualifiers discards qualifiers问题

    百思不得其解,于是百度,google吧.. 发现Stackoverflow上也有人有相同的问题 下面是他的问题: For my compsci class, I am implementing a S ...

  10. android--屏幕旋转方法总结

    在介绍之前,我们需要先了解默认情况下android屏幕旋转的机制: 默认情况下,当用户手机的重力感应器打开后,旋转屏幕方向,会导致当前activity发生onDestroy-> onCreate ...