I am trying to format(add styling) to some text using html and setting that as a text for a textview
Spanned text =Html.fromHtml(""+newAllText);
hello.setText(text, TextView.BufferType.SPANNABLE);
But the Html() method returns Spanned string with all the white spaces removed. I have tried using html tags such a <pre>
but it didn't help..
It is supposed to be shown nicely like this (the html tags was later removed with the from Html() method) but instead all the white spaces are removed and it looks like this (when it is set as text in the ui it looks like one big continuous paragraph).
Anyone has any clue on this?
Just in case if anyone wants to see the full code:
String SelectedSentence =allText.substring(lastPoint, nextPoint);
String highlighted = "<font color='red'>"+SelectedSentence+"</font>";
StringBuilder newAllText = new StringBuilder(allText);
newAllText.delete(lastPoint, nextPoint+1);
newAllText.insert(lastPoint,highlighted);
newAllText = new StringBuilder("<pre>"+newAllText+"</pre>");
Spanned text =Html.fromHtml(""+newAllText);
hello.setText(text, TextView.BufferType.SPANNABLE);
lastPoint = nextPoint;