Is it possible to have multiple styles inside a TextView?

后端 未结 18 1851
醉梦人生
醉梦人生 2020-11-21 17:34

Is it possible to set multiple styles for different pieces of text inside a TextView?

For instance, I am setting the text as follows:

tv.setText(line         


        
18条回答
  •  [愿得一人]
    2020-11-21 17:51

    The list of supported tags is:

    If you use a string resource, you can add some simple styling, such as bold or italic using HTML notation. The currently supported tags are: B (bold), I (italic), U (underline), TT (monospace), BIG, SMALL, SUP (superscript), SUB (subscript), and STRIKE (strikethrough). So, for example, in res/values/strings.xml you could declare this:

    
        We are so glad to see you.
    
    

    (From http://developer.android.com/guide/faq/commontasks.html#selectingtext — Web Archive link, typo is in original!)

    It also shows that Html.fromHtml isn't really needed in simple cases.

提交回复
热议问题