"如何显示在Android的DIV HTML内容上的TextView [英] "How to display div html content in android on textview

查看:1885
本文介绍了"如何显示在Android的DIV HTML内容上的TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对字符串值:

String htmlValue = "<div style="text-align: center;"><span style="font-family: impact, chicago; font-size: 18px;">Exchange Offer !!&nbsp;</span></div>
    <div style="text-align: center;"><span style="font-size: 14px;">any mobile phone</span> , <span style="font-size: 14px;">give your</span> <span style="font-family: impact, chicago; font-size: 20px;">take new one</span>.</div>";

和如何显示包含在TextView中这种类型的分区。

and how to display such type div included in textview.

我也试试这个,但只有内容显示格样式无法显示。

I have try this but only content display div styling could not display.

Spanned result= Html.fromHtml(htmlValue);
tvFooter.setText(result);

 tvFooter.setText(Html.fromHtml(htmlValue));

下面定义:的http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html ,DIV支持,但可以通过上面做得到确切的预期输出。
我有两个以上的把戏,但没有工作。

Here Defined: http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html , div supported but could get exact expected output by doing above. I have both of above trick, but not working.

错误输出:

预计产量像这样

:

推荐答案

当我扫描的 /框架/基/核心/ JAVA /安卓/文本/ Html.java 的,属性风格和标记跨度不被支持。建议使用web视图,而不是TextView的

As I scanned the source code of /frameworks/base/core/java/android/text/Html.java , the attribute style and the tag span are not supported. Suggest using webview instead of textview

以下标签或属性似乎在棒棒堂的支持,

Following tags or attributes seems to be supported in Lollipop,

 - <br>
 - <p>
 - <div>
 - <strong>
 - <b>
 - <em>
 - <cite>
 - <dfn>
 - <i>
 - <big>
 - <small>
 - <font color="..." face="...">
 - <blockquote>
 - <tt>
 - <monospace>
 - <a href="...">
 - <u>
 - <sup>
 - <sub>
 - <h1>
 - <h2>
 - <h3>
 - <h4>
 - <h5>
 - <h6>
 - <img src="...">

这篇关于&QUOT;如何显示在Android的DIV HTML内容上的TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆