Flex 4.6 - Spark 标签的可见高度

发布于 2024-12-20 14:49:11 字数 477 浏览 4 评论 0原文

我正在尝试确定在运行时变为多行的 Spark 标签的高度(由于设置了 width 属性),以解决文本溢出的问题。

(对于名为 Title 的 Spark 标签)我尝试过:

Title.measureText(Title.text).height - 这似乎只返回一行的高度。 (由于屏幕尺寸和字体渲染不同,我事先不知道文本会溢出到多少行...)

Title.height - 这似乎返回标签的高度size(在运行时重新调整多行文本流之前)

即使在 .text 中填充了不同的文本长度/多行长度,上面的两个属性也返回一个不变的值

是否真的没有办法确定溢出的准确高度火花标签


诚然,我对 Flex API 不太熟悉,但在浏览了相当长一段时间的手册后,我仍然无法以正确的间距放置此标题标签。任何帮助将不胜感激。

I am trying to determine the height of a Spark label that becomes multiline at runtime (due to width property being set), to account for text overflow.

(For a spark label named Title) I have tried:

Title.measureText(Title.text).height - this seems to return only the height of one line. (Due to differing screen-sizes and font rendering, I don't know in advance how many lines the text would overflow to...)

Title.height - this seems to return the height of the label size (before being re-adjusted at runtime for multiline text flow)

Both properties above return an unchanging value even when different text lengths/multiple lines long are filled in .text

Is there really no way to determine the exact height of an overflow Spark label?


I am admittedly not that familiar with the Flex API but after scouring the manual for quite some time, I am still unable to place this title label with the proper spacing. Any help would be appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘落散花 2024-12-27 14:49:11

我认为 Spark 标签的 resize 事件会很有用。
只需尝试这个示例应用程序这可能会帮助您

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" >

<fx:Script>
    <![CDATA[
        public var Height:String="";
        public function Resize():void
        {
            Height=lblLabel.height.toString();
            txtText.text="Label Height:  "+Height;
        }
        public function AddText():void
        {
            lblLabel.text += lblLabel.text;
        }


    ]]>
</fx:Script>
    <mx:Text id="txtText"  x="46" y="44" width="200"/>
    <s:Label  id="lblLabel" text="Label Text " x="46" y="99" width="200"  resize="Resize()"/>
    <s:Button id="btnClick" label="AddText" click="AddText()" x="199" y="43"/>
</s:Application>

I think resize event of Spark label will be usefull.
just try this example application This may Help You

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" >

<fx:Script>
    <![CDATA[
        public var Height:String="";
        public function Resize():void
        {
            Height=lblLabel.height.toString();
            txtText.text="Label Height:  "+Height;
        }
        public function AddText():void
        {
            lblLabel.text += lblLabel.text;
        }


    ]]>
</fx:Script>
    <mx:Text id="txtText"  x="46" y="44" width="200"/>
    <s:Label  id="lblLabel" text="Label Text " x="46" y="99" width="200"  resize="Resize()"/>
    <s:Button id="btnClick" label="AddText" click="AddText()" x="199" y="43"/>
</s:Application>
尴尬癌患者 2024-12-27 14:49:11

如果我正确理解您的问题,您可以收听 mx.events.FlexEvent.UPDATE_COMPLETE

If I understood your question correctly, you can listen to mx.events.FlexEvent.UPDATE_COMPLETE

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文