How to display HTML in TextView?
A1.
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 (< Android Nougat):
For example (>= Android Nougat):
|
A2.
If you want to be able to configure it through xml without any modification in java code you may find this idea helpful. Simply you call init from constructor and set the text as html
Java
xml:
TextView myTextview = (TextView) findViewById(R.id.my_text_view); |
Comments
Post a Comment