2

I have such String:

<p><span style="color: rgb(230, 0, 0);">should be text color red</span></p><p><br></p><p><br></p><p><span style="background-color: rgb(230, 0, 0);">should be text color red background</span></p>

Is there a way to display it in TextView?

I wanted to do this like that: contentTextView.setText(Html.fromHtml(presentation.content),TextView.BufferType.SPANNABLE)

Or is there any library for overcoming my issue?

9
  • If fromHtml isn't doing it, you'd have to write your own parser and create the appropriate Spannables. Possibly up to and including creating custom Spannables. Using HTML for text is really not something heavily encouraged in Android. Commented Mar 16, 2018 at 14:02
  • @GabeSechan yep, but i really need to use HTML because of retrieving it same as in the backend HTML editor which i need to display also in the Android app, same formatted as there Commented Mar 16, 2018 at 14:04
  • 1
    Then you may want to use a webview, if you're displaying HTML content. But that's pretty much your options: fromHtml, a webview, or doing all your own HTML parsing to create Spannables (or finding a library that does it). Commented Mar 16, 2018 at 14:07
  • Can you see this stackoverflow.com/questions/49323455/… Is there possibility that the content is loading that fast that the progressBar is not appeariing at all? However I need this(there is like 1 second loading) Commented Mar 16, 2018 at 14:59
  • github.com/Pixplicity/HtmlCompat Commented Mar 16, 2018 at 18:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.