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

原文地址:https://blog.csdn.net/aiguoguo000/article/details/72842223

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);  

猜你喜欢

转载自blog.csdn.net/chenhuakang/article/details/81301933