【问题标题】:Flex Mobile Text wrap around imageFlex Mobile 文本环绕图像
【发布时间】:2013-05-26 21:50:52
【问题描述】:

我正在尝试为 Flex Mobile 应用程序创建一个组件,该组件允许我拥有一个带有文本环绕的图像,这在文章或博客文章中很常见。使用 HTML,这可以通过如下标签来完成:

<image align='right' /> associated text...

我尝试创建一个 s:TextArea,并将其文本设置为 HTML 字符串,如下所示:

StyleableTextField(textArea.textDisplay).htmlText = htmlString

但是这个方法好像不支持图片。我可以使用单独的图像和文本组件,但文本不会按照我想要的方式环绕图像。

谁能提出更好的方法?

【问题讨论】:

  • 您有问题吗?文本布局框架 (TLF) 专为执行此类操作而设计,但我不确定它是否在移动设备上受支持。出于性能考虑,Flex 移动皮肤不使用 TLF。

标签: html image apache-flex mobile


【解决方案1】:

这可以使用TextFlow 执行,显示为:

使用TextConverterimportToFlow()作为composer来组装html:

<?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">

    <fx:Script>
        <![CDATA[
            import flashx.textLayout.conversion.TextConverter;
            import flashx.textLayout.elements.TextFlow;

            private const text:String = "<img src='http://www.google.com/images/srpr/logo4w.png' " +
                "align='right' width='138' height='48' />Lorem ipsum dolor sit amet, " +
                "consectetur adipiscing elit. Nunc sodales posuere elit nec convallis. " +
                "Vivamus lacinia consectetur tortor, in convallis diam ornare sit amet. " +
                "Morbi volutpat volutpat aliquet. Praesent hendrerit nibh et magna feugiat " +
                "laoreet. Maecenas congue rhoncus tincidunt. Aliquam libero dui, scelerisque " +
                "eu convallis at, consectetur vitae dolor. Nunc quis posuere tellus.";
        ]]>
    </fx:Script>

    <s:RichEditableText editable="false"
                        selectable="true"
                        textFlow="{TextConverter.importToFlow(text, TextConverter.TEXT_FIELD_HTML_FORMAT)}"
                        buttonMode="true"
                        width="100%"
                        height="100%" />

</s:Application>

注意AIR也有StageWebView,使用设备操作系统提供的系统web控件。

【讨论】:

  • 毫无价值,正如我在帖子的评论中所说,Flex Mobile 项目中默认不包含 Text Layout Framework,并且默认的移动 Skins 不使用 Text Layout框架。 RichEditableText 不是移动设备支持的组件。他必须克服一些困难才能让这个解决方案在移动设备上运行;而且我不知道它的表现会如何。
  • 是的,Flex Mobile 不支持这些,我不想通过尝试嵌入 TLF 来降低性能并增加文件大小。这似乎是一件如此简单的事情,令我惊讶的是,使用受支持的组件并不容易实现。我想我没有错过一个明显简单的解决方案。
  • 当然不鼓励使用它;但是,StageWebView 是另一种选择,具体取决于您的要求程度。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-18
  • 2022-06-29
  • 2013-07-02
  • 2015-01-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多