您的位置:首页 > 其它

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

2017-06-02 10:50 1001 查看
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); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: