Android中有时需动态设置控件四周的drawble图片,这个时候就需要调用 setCompoundDrawables(left, top, right, bottom),四个参数类型都是drawable
Resources res = getResources();
Drawable img_off = res.getDrawable(R.drawable.dianzan_click);
img_off.setBounds(0, 0, img_off.getMinimumWidth(), img_off.getMinimumHeight());<span style="font-family: Arial, Helvetica, sans-serif;">//必须调用Drawable.setBounds()方法,否则图片不显示</span>
holder.tvTopCount.setCompoundDrawables(img_off, null, null, null); //设置左图标