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

Viewed 64244

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.

12 Answers

For color text with hyperlink URL:

textView.setText(Html.fromHtml("You agree to our <font color='#F20000'><a href='https://www.yoururl.com'> Terms of Service</a></font> and <font color='#F20000'><a href='https://www.yoururl.com'>Privacy Policy</a></font>", Html.FROM_HTML_MODE_LEGACY), TextView.BufferType.SPANNABLE);

This worked for me and I am sure it will also work for all.

Related