2

I am dealing with the following html

<div style="font-size:14px; font-weight:bold;"> My Text </div>

When using the class html.fromHtml to display my html into a textview I lose the text properties. How can I display the html in a text view properly?

user859348
  • 359
  • 1
  • 3
  • 13
  • this should help http://stackoverflow.com/questions/2159847/is-there-any-example-about-spanned-and-spannable-text – Snicolas Aug 22 '11 at 13:10
  • i tried this but it didn't work.. int n = escapedHtml.indexOf("
    "); int m = escapedHtml.indexOf("/div"); if (n!=-1){ try{ escapedHtml=escapedHtml.replace("
    ", "

    "); escapedHtml=escapedHtml.replace("

    ", ""); } catch (Exception e){ } }
    – user859348 Aug 22 '11 at 13:43
  • 1
    my solution was - use a web view instead – user859348 Aug 22 '11 at 14:43

1 Answers1

3

You should check this,
http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html,
only few tags are supported.

You might have to use some parsers to get the values you want and set them dynamically through the code.

sat
  • 40,138
  • 28
  • 93
  • 102