Render HTML in TextView in Android

html code escape

<![CDATA[
      html code here
]]>

html string in string resource xml in Android

<string name="a_string">
<![CDATA[
This string contains <b>html</b> code
]]>
</string>

Using Html.fromHtml to render string with html code

TextView tvHtmlStr = (TextView)findViewById(R.id.tv_string);
tvHtmlStr.setText(Html.fromHtml(getString(R.string.a_string)));

Reference:
https://developer.android.com/guide/topics/resources/string-resource.html

Search within Codexpedia

Custom Search

Search the entire web

Custom Search