If I have html with tags not supported as part of Html.fromText I understand a WebView will do the trick as it supports standard HTML as a browser but its performance is really slow to my liking. So if I don't want to use WebView, the only other way is to parse the HTML myself and put different tags in muliple TextView inside a vertical LinearLayout?
Asked
Active
Viewed 1,283 times
0
Prasanna
- 3,553
- 7
- 45
- 73
2 Answers
4
You'll have to use Html.fromHtml() with an Html.TagHandler to handle unknown tags like <pre/> and <code/>.
See this answer for an example of how to implement Html.TagHandler.
Community
- 1
- 1
Dheeraj Vepakomma
- 19,992
- 13
- 70
- 98
1
Use replaceAll() to convert the <pre> and <code> tags to <tt>, which is supported by Html.fromHtml(). Then, use Html.fromHtml() to create the SpannedString that you pass to the TextView.
CommonsWare
- 954,112
- 185
- 2,315
- 2,367
which are not getting rendered in `TextView` – Prasanna Mar 26 '12 at 17:49