Android App Not Rendering Html Tags Very Well
Solution 1:
It may help you I was also getting same issue in my project and this worked for me.may be it will help you:
Stringreply= parent.getString(TAG_ReplyMessage);
TextViewReplyTextView= findViewById(R.id.reply_txt);
Stringhtmltext= Html.fromHtml(reply).toString();
ReplyTextView.setText(Html.fromHtml(htmltext));
Solution 2:
Android does not support all HTML tags.
This is a, albeit a bit old, list of supported HTML tags: http://www.grokkingandroid.com/android-quick-tip-formatting-text-with-html-fromhtml/
Or you could look through the sources and see which are supported: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/text/Html.java#Html
According to those lists, <p>
is not supported. So it can't parse anything within <p></p>
.
Solution 3:
&#39;
remove amp;
part. Html code for '
single quote is just '
Solution 4:
You can write those tags directly between <![CDATA[...]]>
in strings.xml
.
Example:
<stringname="type"><![CDATA[Type:<B> %s</B>]]></string>
In Java:
textView.setText(Html.fromHtml(getString(R.string.type, "Sports")));
Output:
Type: Sports
Update:
If string itself is like:
String data = "<p><strong>This is instructor&#39;s reply to the guest&#39;s MDB message</strong></p>";
Then, you can try as below:
textView.setText(Html.fromHtml(Html.fromHtml(data).toString()));
Post a Comment for "Android App Not Rendering Html Tags Very Well"