android - Android 新数据绑定(bind)库中的 HTML 格式化

标签 android data-binding

使用新的 data binding library对于 Android,我可以仅通过 XML 为 TextView 使用 HTML 格式,还是必须以编程方式使用 Html.fromHtml

最佳答案

您必须导入 Html 然后调用 fromHtml 方法:

<data>
    <import type="android.text.Html"/>
</data>
…
<TextView
    android:text="@{Html.fromHtml(@string/my_html)}"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"/>

关于android - Android 新数据绑定(bind)库中的 HTML 格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31778414/

相关文章:

Android - 在 AlertDialog TextView 中自动滚动

android - 使用okhttp multipart将图像从Android上传到服务器

c# - WPF DataGrid - 将数据项的属性绑定(bind)为 CommandParameter

data-binding - 与用户控件的动态绑定(bind)不起作用,因为静态在 Silverlight 和 MVVM 中有效

c# - 使用 WPF/C# 中的绑定(bind)获取更改的数据

在没有 InvokeRequired 的多线程场景中,Winforms 数据绑定(bind)到业务对象?

android - 如何使用 Spinner 显示玩家的名字并通过 Intent 发送?

android - 如何查找任何 Android 应用程序的用户花费时间

java - 如何在 Android 中使用 cordova 创建一个基本的应用程序类

java - Android (Kotlin) 与非字符串基元类型的双向数据绑定(bind)