Show in html textview with inline styles

I need to show html with inline styles in my application. There is a lot of text that should be in different views , so I can not use Webview (I tried to use a lot of webviews, but the application becomes very slow). As I know, TextView can display html but it cannot display html with inline styles. So what should I do? Is there a way to show this or only generate html with simple tags from html with inline styles ?

So, I need to show html as follows:

<p style="text-align: center;"><span style="color: #ff0000; font-size: 36pt; font-family: 'comic sans ms', sans-serif;">Article Title</span></p> 

But TextView cannot understand the style.

+5
source share
1 answer

Android native TextView does not support all HTML tags and functions. It supports only a few tags and properties . So, in your case there are several options that you can consider.

  • Use WebView to display rich texts. However, WebView too heavy and slow.

  • Use third-party libraries that enhance your own TextView and support more HTML tags. For example: HTML-TextView .

+6
source

Source: https://habr.com/ru/post/1235873/


All Articles