如何以包含富文本的垂直宽度显示一个组,并将其高度设置为适合富文本?

时间:2010-11-20 14:36:51

标签: layout flex4

在这里,我希望在更改为状态后使notifyPanel可见,并进行平滑过渡。但我想让notifyText拥有它自己的高度,我的意思是如果它的多线有一些高度,如果没有,还有其他高度。因此,我不能只设置notifyPanel.height = 20

<s:Group width="100%" height="100%" minHeight="10">
        <s:layout>
            <s:VerticalLayout gap="0"/>
        </s:layout>

<!-- Here I want to make notifyPanel visible after changed to it's state, with a smooth transition. But I want to let the notifyText to have it's own height, what I mean is that if it's multiline has some height if not, have other. Because of this i can't just set the notifyPanel.height = 20 -->
        <s:Group id="notifyPanel" width="100%" minHeight="0">
            <s:Rect height="100%" width="100%">
                <s:fill>
                    <s:SolidColor color="#48E200"/>
                </s:fill>
            </s:Rect>
            <s:RichText id="notifyText" color="#ffffff" top="5" left="10" bottom="5" right="10" text="RichText"/>
        </s:Group>


        <s:Group height="100%" width="100%">
            <s:Rect height="100%" width="100%">
                <s:fill>
                    <s:SolidColor color="#FFFFFF"/>
                </s:fill>
            </s:Rect>
            <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" minWidth="0" minHeight="0"/>
        </s:Group>


    </s:Group>

1 个答案:

答案 0 :(得分:0)

删除宽度&amp;在notifyPanel上的高度,这将导致它的大小为其内容。同时删除notifyText上的约束,以便它也可以调整其内容的大小。通过设置minHeight&amp; amp;来控制整体约束。在notifyPanel上的maxHeight。

<s:Group id="notifyPanel">
   <s:Rect height="100%" width="100%">
       <s:fill>
          <s:SolidColor color="#48E200"/>
       </s:fill>
   </s:Rect>
   <s:RichText id="notifyText" color="#ffffff" text="RichText"/>
</s:Group>