Wednesday 15 July 2015

html - Android Textview Spannable disregards newlines and trailing whitespace -


I am trying to display a piece of code in TextView . Code lines & lt; Pre & gt; & Lt; Code & gt; Before calling on Html.fromHtml () to the string , I can clearly see Tabling and Newline, but when I < Calling code> fromHtml () change it to Spannable , this is & lt; Pre & gt; & Lt; Code & gt; Loses all the whitespacing in the tag.

How does this look HTML :

Before

and here it is after fromHtml :

 after

It is very difficult to read at all. How should I try to fix this? Keep in mind that this is only for & lt; Code & gt; New lines and white spots are in the tag & lt; P & gt; Tags fix new lines

Unless Google added it when I was not looking - they, all other strangers Just like the tag, the bus is snatched.

You can try using TagHandler here, but I have a disagreement that it will help a lot with the Newlands.

What you might be able to do is & lt; Pre & gt; tag and lt; P & gt; tag (if you like & lt; p & gt; Newline handling), then use TagHandler & Lt; Code & gt; Change to a monospace TypefaceSpan .

In a list containing 18,000 items, write a better fromHtml () replacement ...

No comments:

Post a Comment