Is it possible to have multiple styles inside a TextView?

后端 未结 18 1865
醉梦人生
醉梦人生 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 18:14

    Spanny make SpannableString easier to use.

    Spanny spanny = new Spanny("Underline text", new UnderlineSpan())
                    .append("\nRed text", new ForegroundColorSpan(Color.RED))
                    .append("\nPlain text");
    textView.setText(spanny)
    

提交回复
热议问题