getmeasuredwidth专题

【Android】getwidth和getmeasuredwidth的区别以及两者的使用场景

首先,看getWidth()的官方说明: public final int getWidth () Added in API level 1 Return the width of the your view. Returns The width of your view, in pixels. 返回view的宽度,说的不详细,再看getWidth源码: <

getWidth()与getMeasuredWidth()的区别

getWidth()与getMeasuredWidth()的区别 一般在自定义控件的时候getMeasuredWidth/getMeasuredHeight它的赋值在View的setMeasuredDimension中,所以有时可以在onMeasure方法中看到利用getMeasuredWidth/getMeasuredHeight初始化别的参数。而getWidth/getHeight一直在on