I am trying to place html into a TextView. Everything works perfectly, this is my code.
String htmlTxt = "<p>Hellllo</p>"; // the html is form an API
Spanned html = Html.fromHtml(htmlTxt);
myTextView.setText(html);
This sets my TextView with the correct html. But my problem is, having a
tag in the html, the result text that goes into the TextView has a "\n" at the end, so it pushes my TextView's height higher than it should be.
Since its a Spanned variable, I can't apply regex replace to remove the "\n", and if I was to convert it into a string, then apply regex, I lose the functionality of having html anchors to work properly.
Does anyone know any solutions to remove the ending linebreak(s) from a "Spanned" variable?
<br/>
) instead? You can place the line break before the text, and nothing after so it's: <br/>Hellllllllooooo , which will give it a break above the text, but nothing below it. – Minnie