Android Html.fromHtml(String) doesn't work for <font color='#'>text</font>

android, textview

Solution

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.

Problem

I am trying to add lines with different colors to my TextView using html tags. For whatever reason, ``` Html.fromHtml("<font color='#145A14'>text</font>"); ``` won't show up colored in the TextView.

Original source