What is unit of parameter value in onMeasure(int widthMeasureSpec, int heightMeasureSpec) method of View Class?
Can Any body let me know what is the 开发者_运维百科unit of parameter of onMeasure(int widthMeasureSpec, int heightMeasureSpec) this View Class Method.
I print the log it return me 1073742144,-2147483251 respectively.
The value is a combination of mode and size. Use View.MeasureSpec.getMode(widthMeasureSpec)
to get the mode (one of MeasureSpec.EXACTLY
, MeasureSpec.AT_MOST
and MeasureSpec.UNSPECIFIED
); what you probably want to know is View.MeasureSpec.getSize(widthMeasureSpec)
, the size in pixels.
See also the source code of MeasureSpec.
精彩评论