I have simple HTML:
<h2>Title</h2><br>
<p>description here</p>
I want to display HTML styled text it in TextView
. How to do this?
I have simple HTML:
<h2>Title</h2><br>
<p>description here</p>
I want to display HTML styled text it in TextView
. How to do this?
Whenever you write custom text view basic HTML set text feature will be get vanished form some of the devices.
So we need to do following addtional steps make is work
setText(Html.fromHtml(bodyData)) is deprecated after api 24. Now you have to do this:
Have a look on this: https://stackoverflow.com/a/8558249/450148
It is pretty good too!!
It works only for few tags.
It's worth mentioning that the method Html.fromHtml(String source) is deprecated as of API level 24. If that's your target API, you should use Html.fromHtml(String source, int flags) instead.
I would like also to suggest following project: https://github.com/NightWhistler/HtmlSpanner
Usage is almost the same as default android converter:
Found it after I already started by own implementation of html to spannable converter, because standard Html.fromHtml does not provide enough flexibility over rendering control and even no possibility to use custom fonts from ttf
Make a global method like:
You can also use it in your Activity/Fragment like: