How to remove drawableleft

后端 未结 6 714
攒了一身酷
攒了一身酷 2020-12-29 01:06

I have a button and a text-view, text-view has a drawable-left. After click on button the drawable-left should be removed and a plain text should be set to Text-view, but I

6条回答
  •  感情败类
    2020-12-29 01:32

    Add a Kotlin Extension

    If you are going to be doing this frequently, adding an extension makes your code more readable

    fun TextView.clearDrawables() {
        this.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
    }
    

    To use the extension, simply call

    view.clearDrawables()
    

提交回复
热议问题