Android Html.fromHtml(String)不适用于< font color ='#'> text</font> [英] Android Html.fromHtml(String) doesn't work for <font color='#'>text</font>

查看:112
本文介绍了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>");

请使用以下内容代替上面的内容

Instead of above please use following

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)不适用于&lt; font color ='#'&gt; text&lt;/font&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆