首页 > 解决方案 > 将 RemoteViews 中的 TextView 设置为 CSS 样式的 html 文本

问题描述

我正在使用以下代码在 a 中设置文本TextView(本身在 aRemoteViews中),htmlText下面是用 html 标记包装的文本,包括用于设置文本颜色和粗细的 css 样式:

Spanned styledText = Html.fromHtml(htmlText, FROM_HTML_MODE_LEGACY);
remoteViews.setTextViewText(R.id.text_view, styledText);

文本至少被解释为 html 文本(即我看到文本,而不是标记),但是诸如style="font-size:52.03px;font-weight:bolder;color:rgba(51, 51, 51, 1);"被忽略的样式......我特别希望文本颜色得到尊重......不那么在意重量和尺寸。

如何让 html 标记中的 css 样式得到尊重?

标签: androidhtmltextviewremoteview

解决方案


推荐阅读