How to remove drawableleft

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

    We can sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text.

    Use 0 or null if you do not want a Drawable there.

     textView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
    

    The Drawables' bounds will be set to their intrinsic bounds.

    Calling this method will overwrite any Drawables previously set using {@link #setCompoundDrawablesRelative} or related methods.

    And if we wants to set Drawables then we can use :

    textView.setCompoundDrawablesWithIntrinsicBounds( R.drawable.smiley, 0, 0, 0);
    

提交回复
热议问题