Skip to content Skip to sidebar Skip to footer

"how To Display Div Html Content In Android On Textview

I have value on string: String htmlValue = '
Exchange Offer !! <

Solution 1:

As I scanned the source code of /frameworks/base/core/java/android/text/Html.java , the attribute style and the tag span are not supported. Suggest using webview instead of textview

Following tags or attributes seems to be supported in Lollipop,

 - <br>
 - <p>
 - <div>
 - <strong>
 - <b>
 - <em>
 - <cite>
 - <dfn>
 - <i>
 - <big>
 - <small>
 - <fontcolor="..."face="...">
 - <blockquote>
 - <tt>
 - <monospace>
 - <ahref="...">
 - <u>
 - <sup>
 - <sub>
 - <h1>
 - <h2>
 - <h3>
 - <h4>
 - <h5>
 - <h6>
 - <imgsrc="...">

Solution 2:

You need to write \ before inside " because they're closing your string before they properly end, like Jemshit Iskenderov says.

Also, the tags style and span can't be shown in a textview. Check this link for a list of HTML tags that work in textview.

Solution 3:

All html tags are not supported by Html.fromHtml() check here the supported tags in textview.So better you use webview instead of textview to load the html content. like

 yourwebview.loadData(yourhtmlData, "text/html", "UTF-8");

Post a Comment for ""how To Display Div Html Content In Android On Textview"