Fwl的小花园

  博客园 :: 首页 :: 博问 :: 闪存 :: :: 联系 :: :: 管理 ::

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,

 

 

 


 

 

 

 

posted on 2017-01-03 15:53  Fwl的小花园  阅读(106)  评论(0编辑  收藏  举报