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,297 times
0

Prasanna
- 3,703
- 9
- 46
- 74
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
- 26,870
- 17
- 81
- 104
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
- 986,068
- 189
- 2,389
- 2,491
which are not getting rendered in `TextView` – Prasanna Mar 26 '12 at 17:49