我有一个mx:Text标签,其中包含一些我希望在列表中显示的文字。代码如下。
<mx:List id="projectList"
width="100%"
height="100%"
dataProvider="{project.projectRequirements}"
borderThickness="0">
<mx:itemRenderer>
<mx:Component>
<mx:HBox height="100%"
minHeight="20"
paddingBottom="0"
paddingLeft="0"
paddingRight="0"
paddingTop="0"
width="100%"
horizontalScrollPolicy="off"
verticalScrollPolicy="off">
<mx:Text width="100%"
fontSize="12"
text="{data.requirement.requirementText}"/>
</mx:HBox>
</mx:Component>
</mx:itemRenderer>
</mx:List>
如果我手动将mx:HBox的高度设置为我知道允许多行的高度,那么文本将会换行。我真的希望列表中的每个组件可以是不同的高度,由文本量决定。一些文本是1行,有些是4或5。
答案 0 :(得分:1)
List有一个variableRowHeight属性,默认情况下设置为false。将其设置为true,然后确保您的渲染器没有指定高度(因此它会被测量)。
您不需要将组件包装在HBox中,它可以直接扩展Text。