0

In android I extract a string from a Json and I want to display it in a textView. The text contains html tags and I use fromHtml() method to use this tags.

The problem is that fromHtml ignores multiple spaces. If the input string looks like this:

*****This is the start of the sentence...

The output is:

*This is the start of the sentence...

*represents one space

If I use str.replace(" ", " "); I'll get the desired white spaces but the words split in textView because   is a non-breaking space.

And if I use replace(" ", " "); nothing happens. It will not put multiple white spaces.

How can I keep get multiple white spaces while using fromHtml() method ?

cat15ets
  • 167
  • 9
  • As you probably read from [other questions](https://stackoverflow.com/questions/16311416/html-fromhtml-removes-double-space), the HTML spec says the white spaces should be removed if possible. If you share more about your case, we might be able to help find a workaround. – JonZarate Jul 18 '21 at 22:21

0 Answers0