How to remove drawableleft

后端 未结 6 712
攒了一身酷
攒了一身酷 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:37

    How to do this and apply to any of the four drawables with DataBinding

    @BindingAdapter(value = [
    "leftDrawable",
    "topDrawable",
    "rightDrawable",
    "bottomDrawable"], requireAll = false)
    fun setCompoundDrawables(textView: TextView,
                         @DrawableRes left: Int?,
                         @DrawableRes top: Int?,
                         @DrawableRes right: Int?,
                         @DrawableRes bottom: Int?) {
    
    textView.setCompoundDrawablesWithIntrinsicBounds(
        left ?: 0,
        top ?: 0,
        right ?: 0,
        bottom ?: 0
    )}
    

提交回复
热议问题