在 android 的文本视图中显示丰富的 html 文本框

Display a rich html textbox into a text view in android

我在管理控制面板中有一个富文本视图(我不知道它的确切名称,但如下图所示),允许管理员编写产品描述

我有一个 api,return 这个文本框的代码,它 return 上面的文本是这样的:

<ul><li>激活用户角色价格的简单产品</li><li>没有口味和尺寸<br></li></ul><br>

我的问题是如何在我的 apk 中将这种富文本视图代码显示到文本视图中

编辑:我尝试使用 fromHtml 方法,但它不起作用,可能是因为我有 html 标签,例如 ulli?

您可以使用 WebView 来显示您的 HTML 数据,如下所示

val webView = findViewById<WebView>(R.id.my_webview)
val text = "<ul><li>Simple product with user role price activited</li><li>Without flavor and size<br></li></ul>"
webView.loadDataWithBaseURL(null, text, "text/html", "utf-8", null)