Android show html in TextView

In order to show html in a TextView you need to use function Html.fromHtml().

You can pass html text in this function.
below is the example.

If your android os is below the Nougat then you can use below syntext

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>"));

If your android os is Nougat or upper version you can use below syntext.

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>", Html.FROM_HTML_MODE_COMPACT));

Leave a Reply

Your email address will not be published. Required fields are marked *

eight + 16 =