Apache flex 具有不同大小文本的灵活列表
我有一个名为authors的ArrayCollection,里面有很多不同大小的文本。我想列出所有关于作者的信息,每个项目都有一个大小根据文本。代码如下:Apache flex 具有不同大小文本的灵活列表,apache-flex,list,text,Apache Flex,List,Text,我有一个名为authors的ArrayCollection,里面有很多不同大小的文本。我想列出所有关于作者的信息,每个项目都有一个大小根据文本。代码如下: <mx:List dataProvider="{authors}"> <mx:itemRenderer> <mx:Component> <mx:VBox width="100%"> <mx:Text text=
<mx:List dataProvider="{authors}">
<mx:itemRenderer>
<mx:Component>
<mx:VBox width="100%">
<mx:Text text="{data.name}"/>
<mx:Text text="{data.about}" width="100%"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:List>
我试过很多不同的方法,但都没有效果。有什么想法吗?Thx您是否尝试过使用fontSize属性
<mx:List dataProvider="{authors}">
<mx:itemRenderer>
<mx:Component>
<mx:VBox width="100%">
<mx:Text text="{data.name}" fontSize='30'/>
<mx:Text text="{data.about}" width="100%"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:List>
或者,使用htmlText属性将允许您使用HTML格式化文本:尝试以下操作:
<mx:List dataProvider="{authors}" height="300" variableRowHeight="true" width="200">
<mx:itemRenderer>
<mx:Component>
<mx:VBox paddingLeft="0" paddingRight="0">
<mx:Text text="{data.name}" />
<mx:Text text="{data.about}" width="{explicitWidth}" />
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:List>
name字段没有问题,我的问题是about字段有很多行文本,有时是1行,有时是7行,等等,我需要根据文本的高度来确定项目的高度。另外autoSize=True,请参见,问题出在variableRowHeight,而width=“{explicitWidth}”也很有帮助。