How to add new line in html format in android?

I need to add text to the button in bold in the first line and expand the second, but I can’t determine which newline character.

b.setText(Html.fromHtml("<b>" + st + "<\b>" + "\n" + cursor.getString(1)));

ive also tried

b.setText(Html.fromHtml("<b>" + st + "<\b>" + "<br/>" + cursor.getString(1)));

the second one works, but both lines are bold.

Thanks in advance

+5
source share
2 answers

Instead of using HTML to format your text (which is relatively slow), you can use Spans, which give you much tighter control and are more efficient. I wrote a blog post about using runs that can help you get started.

-2

:

b.setText(Html.fromHtml("<b>" + st + "</b>" + "<br/>" + cursor.getString(1)));
+22

All Articles