Android: Set HTML in Text View
Have you ever stuck while customizing text inside your text view? Like using list, different font, color etc. Sure we can use Spannable string, but it is very complicated if you want to make extensive customization.
Fear Not! we can just use HTML inside our text view. We can do immense customization to our text using HTML. We just need to use one line of code to put HTML in our text view.
Add below method to your project
Use it in the project
And Voilà you are done. You have successfully used HTML in your textview.
Important Note
After looking into the android Source code and from a quick look at the source code, here’s what seems to be supported HTML tags as of now.
1.b & strong tag for bold
2. i, em, cite & dfn tag for Italics
3. u tag for Underline
4. sub tag for Subtext
5. sup tag for Supertext
6. big tag for Big
7. small tag for Small
8. tt tag for Monospace
9. h1 to h6 tag for Headlines
10. img tag for image
11. font tag for Font face and color
12. blockquote tag for longer quotes
13. a tag for Link
14. div and p tag for Paragraph
15. br tag for Linefeed
Thank you and I hope this article helped you in some way. If you like the post please support the article by sharing it.🙏 Have a nice day!😀