Bold words in a string of strings.xml in Android

前端 未结 9 2117
甜味超标
甜味超标 2020-12-01 02:44

I have a long text in one of the strings at strings.xml. I want to make bold and change the color of some words in that text.

How can I do it?

9条回答
  •  误落风尘
    2020-12-01 02:56

    As David Olsson has said, you can use HTML in your string resources:

    
        A string with actual formatting!
    
    

    Then if you use getText(R.string.my_string) rather than getString(R.string.my_string) you get back a CharSequence rather than a String that contains the formatting embedded.

提交回复
热议问题