
我有用间隔线等格式设置的纯文本数据.但是我想将此文本显示为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);解决方法:
考虑这个Html display formatted text
您只需要将文字放在
<pre>标记并使用CSS
white-space: pre-wrap;属性以不显示水平滚动来显示它
<pre > Formated text line 2 with wIDe spaces</pre>对于演示,请检查this.
总结以上是内存溢出为你收集整理的android-需要在HTML webview中显示文本格式的数据,例如Stack Overflow全部内容,希望文章能够帮你解决android-需要在HTML webview中显示文本格式的数据,例如Stack Overflow所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)