绝对能用-动态设置textview的drawableleft、drawableright、drawabletop、drawablebottom

项目催的紧,轻信百度导致被坑了(网上全都是这行代码
  1.  setCompoundDrawables  (Drawable left, Drawable top, Drawable right, Drawable bottom);  
),根本行不通!!!!为textview动态设置drawableleft、drawableright、drawabletop、drawablebottom的正确姿势是:
Drawable drawable = getResources().getDrawable(R.mipmap.ic_launcher);
//一定要加这行!!!!!!!!!!!
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
textView2.setCompoundDrawables(drawable,null,null,null);

你可能感兴趣的:(绝对能用-动态设置textview的drawableleft、drawableright、drawabletop、drawablebottom)