简体   繁体   中英

Android and formatting text with html

This may be an elementary question for some but I've been looking at this for the past couple of hours. In the string below, the newlines don't appear and the font-size doesn't change. The newline seems like it should work with no problem but it's not:

String tempStr = "<font color='blue'>" + mUserName + " </font>" + "<font color='black'>" + " \"" + some.toString() + "\" " + "</font>" + "<font size=6>" + timespan + "</font>";

result.setText(Html.fromHtml(tempStr) + "\n\n\n");

Newlines in HTML should be <br>, <p> or even <div > ? I would suggest using inline CSS styles instead. I have not tried that with fromHtml, but it should work?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM