在带有内联样式的textview html中显示 [英] Show in textview html with inline styles
问题描述
我需要在我的应用中使用内联样式显示html。
有很多文本必须在不同的视图所以我不能使用Webview(我试图使用很多Webviews,但应用程序变得很慢)。我知道TextView可以显示html,但它不能显示带有内联样式的html。
那么,我该怎么办?
有没有什么方法可以显示它,或者只从html中用内联样式生成简单标签的html?
I need to show html with inline styles in my app. There are a lot of text that must be in different views so I can't use Webview(I tried to use a lot of Webviews but the app becomes very slow ).As I know TextView can show html but it can`t show html with inline styles. So, what should I do? Is there any way to show it or to generate only html with simple tags from html with inline styles?
以像这样显示html:
So I need to show html like this:
<p style="text-align: center;"><span style="color: #ff0000; font-size: 36pt; font-family: 'comic sans ms', sans-serif;">Article Title</span></p>
但TextView不能理解样式。
But TextView can`t understand style.
推荐答案
Android原生 TextView
不支持所有HTML标记和功能。它只支持几个标签和属性。
Android native TextView
doesn't support all HTML tags and features. It only does support a few tags and properties. So, in your case, there's a couple of options which you may want to consider.
-
使用
WebView
以显示富文本。
使用第三方库改善原生<$ p $ <$ p>
Use 3rd party libraries that improve native TextView
and support more HTML tags. For example: HTML-TextView.
这篇关于在带有内联样式的textview html中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!