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. js基础和工具库

    /* * 作者: 胡乐 * 2015/4/18 * js 基础 和 工具库 * * * */ //根据获取对象 function hGetId(id){ return document.getElem ...

  2. nodejs package.json详细解读

    package.json详细内容 它是这样一个json文件(注意:json文件内是不能写注释的,复制下列内容请删除注释): JavaScript { "name": "t ...

  3. 矩阵快速幂AC代码HDU 2035

    #include <iostream> using namespace std;const int MOD = 1000;//像这样的一个常量就应该专门定义一下 int PowMod(in ...

  4. 经典.net面试题目(3)

    1. asp.net中web应用程序获取数据的流程: A.Web Page B.Fill  C.Sql05  D.Data Sourse  E.DataGrid  F.DataSet  G.Selec ...

  5. Windows下的ls的命令

    习惯了linux下的ls命令,windows的dir用的很不习惯,又不想装cygwin, bash,就想把dir重命名为ls,发现dos下有个命令doskey可以完成该功能.在命令提示符下敲: > ...

  6. EntityFramwork所有 SSDL 项目都必须以同一提供程序为目标。ProviderManifestToken“2008”不同于以前遇到的“2005”

    再用spring+mvc+EF搭建框架时,出现这个问题,网上没有找到类似的问题,删除实体重建后莫名其妙的好了,2008指的是连得数据库实例是2008版本的,2005指的是2005版本,出现问题的原因是 ...

  7. 【转】RestQL:现代化的 API 开发方式

    原文:http://tech.meituan.com/koa-restql.html RestQL:现代化的 API 开发方式 李鑫 ·2016-08-12 11:26 koa-restql 已经在  ...

  8. ant 配置expdp and impap

    + 执行步骤: ant -f 1_exp_prod.xml copy file from prod to uat (maunule) ant -f  3_imp_uat.xml 附件: 1.1_exp ...

  9. java基础增强

    Eclipse使用: java Compile配置的是java编译环境 java Build path配置的是java运行环境 运行环境的版本必须高于编译环境的版本.否则报错 工程上 右键--prop ...

  10. Loadrunner脚本录制注意事项(七)

    1.手动走一遍被测业务,达到熟悉理解业务,注意是否和服务器有数据交互,为脚本是否需要关联做准备: 2.浏览器选择IE8/9较好,选择其他浏览器可能会有各种问题.(a.IE设置:内容-设置-去掉所有选项 ...