0

How can I get a TextView to show text in more than one color? I'm looking for an effect like:

<span style="color:green;">Question: </span><span> Who was the first president?</span>

I can't use separate TextViews inside a Horizontal Linear Layout since it doesn't display correctly when the text wraps. I also tried using Html.FromHtml but it didn't work since it doesn't support styles on a span tag.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
Matt M
  • 3,699
  • 5
  • 48
  • 76

1 Answers1

1

I also tried using Html.FromHtml but it didn't work since it doesn't support styles on a span tag.

No, but it does support <font color="...">.

Or, use a SpannableString to assemble the string yourself, applying ForegroundColorSpan styles for the appropriate sections.

Or, use a WebView.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491