添加 html 文本到钛标签

add html text to label in titanium

我有一个 html 文本,其中包含一些 html 标签。

我的问题:

如何在没有这些标签的情况下将文本添加到标签中,但保持文本对齐?

例如:

如果我有一个“
”作为标签,我需要在添加到标签的文本中具有相同的效果,但文本中不出现“
”。

我该怎么做?

几个解决方案,如果只是关于间距 (<br>),您实际上可以用正则表达式将 <br> 替换为 \n

如果比较复杂(粗体、斜体、下划线、链接)可以使用Attributed Strings. If it is much more complicated than the supported types in Attributed strings you can use a webview, or StyledLabel

在Android你可以申请

   Html.fromHtml("Html text")

希望对你有所帮助