android setcompounddrawables 可以设置gap么

时间:2016.02.21 发布人:v30mscd2x

android setcompounddrawables 可以设置gap么

已解决问题

谷歌v30mscd2x用户在2016.02.21提交了关于“国**凌凌漆android setcompounddrawables 可以设置gap么”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-10-31T22:30:14。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,没有什么华丽的语言,但是我对你的感谢不会减少 !

希望以下的回答,能够帮助你。

第1个回答

用户名:ipzy520  

手工设置文本与图片相对位置时,常用到如下方法:

setCompoundDrawables(left,top,right,bottom)

setCompoundDr演会国总标爱斤坐送进awablesWithIntrinsicBounds(left,top,right,bottom)

意思是设置Drawable显示在text的左、上、右、下衡位置。

但是两者有些区别
setCompoundDrawables画的drawable的宽高是按drawable.setBound()设置的宽脯
所以才有TheDrawablesmustalreadyh**ehadsetBounds(Rect)called.

使用之前必须使用Drawable.setBounds设置Drawable的长宽。

setCompoundDrawablesWithIntrinsicBounds是画的drawab常念商散le的宽高是按drawable晚益航固定的宽脯
所以才有TheDrawables'boundswillbesettothei卫量考需斯香省弱简名rintrinsicbounds.

即通过getI令ntrinsicWidth()与getIntrinsich**eight()获得,