TextView中设置drawableLeft、drawableRight时设置图片的大小方法

Drawable drawable = context.getDrawable(R.drawable.***);  //(API 21以上才能使用此方法)

//或者:Drawable drawable = context.getResource().getDrawable(R.drawable.***);

drawable.setBounds(0,0,width,height);  //width即为你需要设置的图片宽度,height即为你设置的图片的高度

tv.setCompoundDrawables(null,null,drawable,null); 

你可能感兴趣的:(TextView中设置drawableLeft、drawableRight时设置图片的大小方法)