Android点滴

1,View中getWidth(),getLayoutParams.width,getMeasureedWidth()的区别

2,setCompoundDrawables和setCompoundDrawablesWithIntrinsicBounds 的区别

 

 

1,View中getWidth(),getLayoutParams.width,getMeasureedWidth()的区别

getWidth()在layout执行完后才能获取宽度,在onMeasure()方法中是拿不到的 
  而固定宽度,可以通过layoutParams.width获取,如果是wrap_content也是不能获取的 
getLayoutParams.width可以在onMesure方法中获取 
getMeasureedWidth();在onMeasure()执行完后才会有值 

Height也就类似了。。。

 

2,setCompoundDrawables和setCompoundDrawablesWithIntrinsicBounds 的区别

setCompoundDrawables是要drawable自己设置自己的Bounds,而setCompoundDrawablesWithIntrinsicBounds不用自己设置,会根据drawable的大小来适应

setCompoundDrawablesWithIntrinsicBounds 中,drawable的宽高是通过getIntrinsicWidth()与getIntrinsicHeight()获得。

 

3,

 

 

 

 
 

 

 

 

 

转载于:https://www.cnblogs.com/fwling/p/6244823.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值