【Android】代码中设置drawableLeft|Top|Right|Bottom

XML代码

android:drawableLeft="@drawable/"
android:drawableTop="@drawable/"
android:drawableRight="@drawable/"
android:drawableBottom="@drawable/"

Java代码

Drawable img=getResources().getDrawable(R.drawable.img);
img.setBounds(0, 0, img.getMinimumWidth(), img.getMinimumHeight());  
view.setCompoundDrawables(null, null,img,null);
最后一行代码设置左上右下



你可能感兴趣的:(【Android】代码中设置drawableLeft|Top|Right|Bottom)