Is it possible to have multiple styles inside a TextView?

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

    Me Too

    How about using some beautiful markup with Kotlin and Anko -

    import org.jetbrains.anko.*
    override fun onCreate(savedInstanceState: Bundle?) {
        title = "Created with Beautiful Markup"
        super.onCreate(savedInstanceState)
    
        verticalLayout {
            editText {
                hint = buildSpanned {
                    append("Italic, ", Italic)
                    append("highlighted", backgroundColor(0xFFFFFF00.toInt()))
                    append(", Bold", Bold)
                }
            }
        }
    }
    

提交回复
热议问题