动态设置android:drawableLeft|Right|Top|Bottom

Drawable boundImage;
Resources res = getResources();
boundImage = res.getDrawable(R.drawable.yourimage);
//调用setCompoundDrawables时,必须调用Drawable.setBounds()方法,否则图片不显示
boundImage.setBounds(0, 0, boundImage.getMinimumWidth(), boundImage.getMinimumHeight());
yourview.setCompoundDrawables(boundImage, null, null, null); //设置左图标



你可能感兴趣的:(动态设置android:drawableLeft|Right|Top|Bottom)