Drawable[] compoundDrawables = img.getCompoundDrawables(); Rect bounds = compoundDrawables[1].getBounds(); bd.setBounds(bounds); img.setCompoundDrawables(null, bd, null, null);
一边情况下,用setCompoundDrawablesWithIntrinsicBounds就可以了
Drawable[] compoundDrawables = img.getCompoundDrawables(); Rect bounds = compoundDrawables[1].getBounds(); bd.setBounds(bounds); img.setCompoundDrawables(null, bd, null, null);