TextView with html table

Issue

I have a problem. I want to put in to the “TextView” html format text. I add the like below.

<string name="text"><![CDATA[<table><tr><th bgcolor= #FF0000>some text</th></tr> <tr><td bgcolor= #FF0000> some text</td></tr>]]></string>

and put it into the TextView as:

mInfoText.setText(Html.fromHtml(getString(R.string.text)));

but after run application, displayed text in TextView is not formatted.

Solution

Android TextView doesn’t support the Table tag and that’s the reason you can’t see it in a formatted way. You must use a WebView for this purpose.

To know what are the tags supported check this Html List tag not working in android textview. what can i do?

Answered By – Andro Selva

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published