【发布时间】:2024-01-16 10:01:01
【问题描述】:
有没有办法控制 Flex 中数据网格单元格中的文本定位,以便后续列中的所有文本在同一行上对齐?
【问题讨论】:
标签: apache-flex text formatting cell datagrid
有没有办法控制 Flex 中数据网格单元格中的文本定位,以便后续列中的所有文本在同一行上对齐?
【问题讨论】:
标签: apache-flex text formatting cell datagrid
试试这样的 itemRenderer
<mx:HBox width="100%" height="100%" vertical-align="middle">
<mx:Label text="{data.text}"/>
</mx:HBox>
您的文本将排列在相同的baseline 上,假设它的磅值都相同。请注意,所有列都必须使用相同的 itemRenderer,或者类似的。即使是图像、进度条等,我也经常使用这种模式。
【讨论】:
使用其中一种标签样式。这些应该适用于大多数事情:
textAlign="left|right|center"
textDecoration="none|underline"
textIndent="0"
这是一个使用 DataGridColumn 的 itemRenderer 的示例:
<mx:DataGrid>
<mx:columns>
<mx:DataGridColumn>
<mx:itemRenderer>
<mx:Component>
<mx:Label width="100%" height="100%" textAlign="center"/>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGridColumn>
如果有帮助,请告诉我! :)
【讨论】: