Make EditText accept and display HTML text

Does anyone know how to create an EditText control that displays html text and even writes HTML text to act as an HTML editing field,

+10
source share
4 answers

To show HTML code in EditText , you need to convert it to Spanned using Html.fromHtml() . Only a small subset of HTML tags can be used in this method. You can set Spanned as EditText . Then you can edit it and convert using Html.toHtml() .

+12
source

Try using Html.fromHtml(text) to display HTML EditText in EditText .

But the Html class can recognize only a few tags, and it is not exhaustive. You can check this blog to see if all tags are currently supported.

+14
source
 String xyz="this <br>is<br> my<br> testing <br>string "; String formattedString =Html.fromHtml(xyz); 
0
source

You can use the spannable strings as described in the blog below: https://medium.com/androiddevelopers/spantastic-text-styling-with-spans-17b0c16b4568

or use the library below: https://github.com/nntuyen/text-decorator

0
source

All Articles