Android TextView fromHtml() how to support unsupported css style, text size?

1.2k Views Asked by At

I'm using this:

HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_LEGACY);

How to add support of text size regarding a fact that font-size isn't natively supported?

I don't want to override whole paragraph text - other styles works well. Using regex or parse html through different library may lead to problems as part of a text may have bigger font or parser may work differently. Also a webview isn't a sollution.

Example html:

<p style="font-size:30px">TEST</p>

1

There are 1 best solutions below

3
Akshay Raiyani On

Android HTML did not support all the tags of HTML. Font color is working fine with Android HTML, but font size is not supported. You can use <small>, <big> tags for Android HTML

Html.fromHtml("<big>" + "First name" + "</big>" + "<br />" + "<small>" + "Last name" + "</small>", Html.FROM_HTML_MODE_LEGACY);

You can check here which tags are supported with Android HTML