Android Html.fromHtml(String) 不适用于 <font color='#'>text</font> [英] Android Html.fromHtml(String) doesn't work for <font color='#'>text</font>
本文介绍了Android Html.fromHtml(String) 不适用于 <font color='#'>text</font>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 html 标签向我的 TextView 添加不同颜色的线条.
I am trying to add lines with different colors to my TextView using html tags.
无论出于何种原因,
Html.fromHtml("<font color='#145A14'>text</font>");
不会在 TextView 中显示为彩色.
won't show up colored in the TextView.
推荐答案
Html.fromHtml("<font color='#145A14'>text</font>");
请使用以下代替上面的
Html.fromHtml("<![CDATA[<font color='#145A14'>text</font>]]>");
这对我有用,我相信它也对你有用.
This worked for me and I am sure it will also work for you.
如果有任何问题,请告诉我.
Let me know in case of any issue.
这篇关于Android Html.fromHtml(String) 不适用于 <font color='#'>text</font>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文