Flex 4 <s:Label 自动换行

Flex 4 <s:Label Word wrap

我尝试用 Label 组件显示文本。 在某些情况下,文本比标签重量长。所以我希望使用类似自动换行的选项来显示两行文本。

 <s:BorderContainer height="26" width="100%" borderStyle="inset" id="bcDos">
     <s:Label text="{phpImportant}" 
              textAlign="center"
              fontWeight="bold" 
              color="#FF0730" 
              fontSize="12"
              paddingBottom="1" 
              paddingTop="1"
              width="100%" 
              height="100%" 
              maxDisplayedLines="2"/>
 </s:BorderContainer>

使用此代码,仅显示 1 行。如果文本多于标签无法显示的内容,Label 会使用截断指示符(例如“...”)为我截断文本。 在我的梦想中,我想在 2 行上自动换行。

感谢您的帮助。

您为 Label 指定了 height26px,其当前字体属性(fontSizefontWeight、.. .) 不能显示多于一行。

因此,要在两行中显示您的文本,您必须使用适当的 height 值或将 属性 保持为空,这样您的标签将自动调整大小:

<s:Label text="{phpImportant}" textAlign="center"
    fontWeight="bold" color="#FF0730" fontSize="12"
    paddingBottom="1" paddingTop="1"
    width="100%" maxDisplayedLines="2"
/>

希望能帮到你。