Detailed Html Android Development Tools

Foreword

  In some demand for rich text editing display or developed under the circumstances, the data are used html format to store text information, while google is to provide the analytical tools that html Html. With Html allows TextView also supports rich text (in fact, the principle is still resolve Html then turn into SpannableString give TextView display)

Html formatted text display

        String htmlContent = "<p> < font size = \" 3 \ "color = \" red \ "> Late emperor did not venture a half and middle Bengcu </ font> </ P>" + 
                        "<B> <font size = \ "5 \" color = \ "blue \"> the third day </ font> </ font> </ B> </ br> "+ 
                        " <h1 of> yizhou Pibi, this despite the critical autumn Cheng also </ h1 of> </ br> " ; 
        mTextView.setText (Html.fromHtml (the htmlContent));

htmlContent some html text format content, and let TextView display rich text content with just one easy call Html.fromHtml (htmlContent) can be. And Html.fromHtml sucked html turned into Spanned
Also note! html format in the "quotation marks need to add \ slash in accordance with the format of java

Renderings:

 

SpannableString converted into text format Html

  Can turn the positive, then of course, we can counter the turn. Let us demonstrate SpannableString converted into text format Html

 

 

 

 

 

 

END

Guess you like

Origin www.cnblogs.com/guanxinjing/p/11231014.html