为什么 Html.fromHtml() 不适用于 <strike> 或 <s> 或 <del> 标签

Why Html.fromHtml() is not not working for <strike> or <s> or <del> tag

基本上,我试图在 html 文本的 textView 上显示 strikeThrough 文本。我已经尝试了所有其他标签,如 bolditalic 等,它们完美显示,没有任何问题,但是当我尝试显示 <strike> or <s> or <del> 标签文本时,它显示的文本没有罢工。谁能帮我解决这个问题?

代码:

 String s="<p dir=\"ltr\"><del>a</del><del>b</del><del>c</del></p> ";
 txtView.setText(Html.fromHtml(s));

好吧,简单地说,它不受支持。 Html.fromHtml() 处理一组不同于静态文本支持的标签。下面是标签列表(不知道是否完整):

<a> (supports attribute "href")
<b>
<big>
<blockquote>
<br>
<cite>
<dfn>
<div>
<em>
<font> (supports attributes "color" and "face")
<i>
<img> (supports attribute "src". Note: you have to include an ImageGetter to handle retrieving a Drawable for this tag)
<p>
<small>
<strong>
<sub>
<sup>
<tt>
<u>

您可以查看源代码here

您必须使用具有扩展功能的库才能使其正常工作,或者您自己编写一个。检查此 one or this one。 Github 上还有很多其他的,或者如果你想写它,我相信你可以通过谷歌搜索找到代码。