I have a Text Editor inside my app, formatting watherver I want into HTML. But I've got a problem when retrieving this from the server (Firestore), because it's showing the whole text+codes, like this:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br><font color="green">Duis non arcu porttitor, laoreet arcu et, egestas justo.</font><br><b>Mauris non pharetra augue, id <i>maximus tellus</i>. Vivamus in sapien nisi.</b>
So this is what is loading inside the TextView, instead of formatted text like it should be. Does anyone knows how to fix it? Thank you in advance!
You can use Html.fromHtml
. It will format your text (html) to display.
val message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br><font color="green">Duis non arcu porttitor, laoreet arcu et, egestas justo.</font><br><b>Mauris non pharetra augue, id <i>maximus tellus</i>. Vivamus in sapien nisi.</b>"
binding.tvMessage.text =
Html.fromHtml(message, Html.FROM_HTML_MODE_COMPACT)
UPDATE:
You are doing it wrong way.
txtPostDesc.setText(Html.fromHtml(postDescription, Html.FROM_HTML_MODE_COMPACT));