TextView添加图片,设置图片大小

添加图片:

android:drawableTop/drawableButtom/drawableLeft/drawableRight
//分别对应在文字的上、下、左、右(在xml中使用)

修改图片尺寸:

//方式一:直接使用ImagView修改尺寸,配合xml使用较好
ImageView tv=(ImageView)View.inflate(container.getContext(),R.layout.inflate_toolbar,null);
tv.setCompoundDrawablesWithIntrinsicBounds(0,iconArr[i],0,0);
tv.setImageResource(iconArr[i]);
//方式二:使用drawable修改图像尺寸
Drawable drawable=tv.getResources().getDrawable(iconArr[i]);
drawable.setBounds(0,0,90,90);
tv.setCompoundDrawables(null,drawable,null,null);

参考:

https://blog.csdn.net/molu_chase/article/details/50805222

https://bbs.csdn.net/topics/391029643

https://zhidao.baidu.com/question/84117550.html

https://blog.csdn.net/hhbgk/article/details/8101676

https://www.cnblogs.com/dukc/p/5137194.html

https://blog.csdn.net/jdsjlzx/article/details/13814041

setBound函数

将drawable绘制在canvas内部(100,100,500,500)表示的矩形区内(这个矩形区域的坐标是以canvas左上角为坐标原点的)

参考:https://blog.csdn.net/zhuhai__yizhi/article/details/79481138

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值