To draw an Underline below the TextView in Android

后端 未结 8 862
孤街浪徒
孤街浪徒 2020-11-29 16:39

I want to draw the underline below my TextView. I have searched a few content but couldn\'t find out anything fruitful.

Can anyone please help me out he

8条回答
  •  离开以前
    2020-11-29 16:40

    You can use Kotlin Extension and type your own drawUnderLine method.

    fun TextView.drawUnderLine() {
        val text = SpannableString(this.text.toString())
        text.setSpan(UnderlineSpan(), 0, text.length, 0)
        this.text = text
    }
    
    yourTextView.drawUnderLine()
    

提交回复
热议问题