Format TextView to look like link

前端 未结 7 1562
醉话见心
醉话见心 2021-01-04 02:21

I\'ve been using the android:autoLink just fine for formatting links and such, but I need to use android:onClick so I can\'t use that in this case.

相关标签:
7条回答
  • 2021-01-04 03:10

    Simply underline it:

    val myText = "Text to be underlined"
    textView.text = Html.fromHtml("<u>$myText</u>")
    

    or with kotlin extensions:

    fun TextView.underline() {
        text = Html.fromHtml("<u>${text}</u>")
    }
    

    usage:

    textView.text = myText
    textView.underline()
    

    More ways to style text in android here: https://medium.com/androiddevelopers/spantastic-text-styling-with-spans-17b0c16b4568

    0 讨论(0)
提交回复
热议问题