-3

I've got encoded html where even tags are encoded into html entities

Some <b> bold </b> text

I'd like to display this as a spanned string in TextView, however the only way to do it is using Html.fromHtml() twice

val decoded = Html.fromHtml("").toString() // Some <b>bold</b> text
val spanned = Html.fromHtml(decoded)

Is there cleaner way to do this?

Lamorak
  • 10,190
  • 8
  • 44
  • 55

1 Answers1

1

You can use cdata:

<string name="string"><![CDATA[Some <b>bold</b> text]]></string>

Then you just pass the text directly into HTML.fromHtml (remember that API 24 has a new call, so you have to take that into consideration)

Zoe
  • 23,712
  • 16
  • 99
  • 132