Programmatically change drawableLeft of Button

后端 未结 5 1289
太阳男子
太阳男子 2021-02-09 00:50

I\'m using a Button

5条回答
  •  没有蜡笔的小新
    2021-02-09 01:26

    The safest way to set the left drawable without changing the values of the other drawables (top, right, and bottom):

    Drawable[] drawables = textViewExample.getCompoundDrawables();
    textViewExample.setCompoundDrawablesWithIntrinsicBounds(leftDrawable, drawables[1], drawables[2], drawables[3]);
    

提交回复
热议问题