Android TextView 支持哪些 HTML 标签? [英] Which HTML tags are supported by Android TextView?
问题描述
Android 的 TextView 类可以通过 HTML.fromHtml() 显示格式化文本,如下所示:TextView 字符串中的 HTML 标记
Android's TextView class can display formatted text via HTML.fromHtml() as explained for example here: HTML tags in string for TextView
TextView 类只能处理一小部分 HTML,但不知道支持哪些标签和属性,哪些不支持.此处给出的摘要:http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html 似乎不正确.例如.<div align="...">不适用于我使用 Android 2.2
The TextView class can only deal with a small subset of HTML, but I do not know which tags and attributes are supported and which are not. The summary given here: http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html does not seem to be correct. E.g. <div align="..."> does NOT work for me using Android 2.2
推荐答案
为所有搜索它的人查找它.
Looked it up for everyone searching for it.
日期:2017 年 7 月
Date: July 2017
来源:https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/text/Html.java
Html.fromHtml 支持:
Html.fromHtml supports:
- p
- ul
- 李
- div
- 跨度
- 强
- b
- 他们
- 引用
- dfn
- 我
- 大
- 小
- 字体
- 块引用
- tt
- 一个
- 你
- 德尔
- s
- 罢工
- 支持
- 分
- h1
- h2
- h3
- h4
- h5
- h6
- 图片
- br
这篇关于Android TextView 支持哪些 HTML 标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!