Android – you need to display data in text format in HTML WebView, such as stack overflow
I have plain text data formatted with space lines and so on. But do I want to display this text as HTML? How can this be done
[American Thinker]
March 1, 2016
[American Thinker] [Navigation Menu]
HomeArchivesVideoCartoonsAboutSearchLoginRules/FAQContactDonations
Merchandise <http://www.americanmethod.com/american-thinker/>
Home Archives Video Cartoons About Search Login More [Down Arrow]
* Rules/FAQ
* Contact
* Donations
* Merchandise <http://www.americanmethod.com/american-thinker/>
American Thinker Blog
Mexican oil giant devastated by oil price decline - 3/1/16 March 1, 2016
The state owned oil company that provides one third of the revenue of the
Mexican government is in a deep crisis, owing to low oil prices,
What I want to display is just like what I want to display on stackoverflow on the web
The problem is that when I say a paragraph, it all seems to string together
The reverse operation HTML. Fromhtml (htmlstring) is supported, but how to convert text into content that can be displayed correctly in HTML? I didn't think of it until I released it, but I really hope it looks like this edited text
to update:
<PRE> </PRE>
Whether I have performed the operation I want, but there is no line feed now, so I must scroll right or left
Update: add content according to the following suggestions. Now I get line breaks, but some lines are as follows:
The state owned oil company that
provides one third of the revenue of
the
Mexican government is in a deep crisis,
owing to low oil prices,
inefficiency, and corruption. The
implications for the United States are
important. More
The Calamitous Climate at
etc etc
This is my HTML:
String htmlstuff = " \n" +
"<html>\n" +
"<header><title>This is title</title></header>\n" +
"<body>\n" +
"<pre style=\"white-space: pre-wrap;\">\n";
htmlstuff=htmlstuff+result;
htmlstuff=htmlstuff+
" </pre>\n"+
"</body>\n" +
"</html>\n";
wv.loadDataWithBaseURL("", htmlstuff, "text/html", "UTF-8", "");
wv.setHorizontalScrollBarEnabled(false);
resolvent:
Consider this HTML display formatted text
You just need to put the text in
<pre>
Tag and use CSS
white-space: pre-wrap;
Property to display it without horizontal scrolling
<pre style="white-space: pre-wrap;">
Formated text
Line 2 with wide spaces
</pre>
For the demo, check this