How to remove drawableleft

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

    The drawableLeft (or any of the similar attributes) XML attribute can be modified (removing a drawable in your case) via code using something like this:

    yourTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    yourTextView.setText("The Text You Need In There");
    

    The constructor for the method is in this order:

    setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)
    

    Read more about the method setCompoundDrawablesWithIntrinsicBounds here

提交回复
热议问题