【发布时间】:2016-06-13 22:15:55
【问题描述】:
我有纯文本数据,其格式为间距线等。但我想将此文本显示为 HTML?如何才能做到这一点。
[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,
我想在 web 上的 stackoverflow 上显示它。
问题是当我把它放在一个段落中时,它看起来都串在一起了。
支持相反的操作 Html.fromHtml(htmlString) ,但是如何将文本转换为在 HTML 中正确显示的内容?直到我发布之前才想到它,但真的希望它看起来像这个编辑文本。
更新:
<PRE> </PRE>
是否有一些我想要的但现在没有发生环绕所以必须向右或向左滚动。
更新:根据下面的建议添加我现在得到句子换行,但有些行如下:
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
这是我的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);
【问题讨论】:
标签: android html android-layout android-webview