更新时间:2023-01-30 22:32:15
您需要使用Html.fromHtml()$c$c>在你的XML字符串使用HTML。简单地引用与HTML中的字符串在布局XML将无法工作。
例如:
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description此处&lt; / P&gt;中));I have simple HTML:
<h2>Title</h2><br>
<p>description here</p>
I want to display HTML styled text it in TextView
. How to do this???
Any help would be appreciated.
You need to use Html.fromHtml()
to use HTML in your XML Strings. Simply referencing a String with HTML in your layout XML will not work.
For example:
myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));