What is the unit of the parameter value in the onMeasure (int widthMeasureSpec, int heightMeasureSpec) method of the View class?

Can any body tell me what is the unit of the onMeasure parameter (int widthMeasureSpec, int heightMeasureSpec) this View Class Method.

I print a magazine, it returns me 1073742144, -2147483251 respectively.

+6
source share
1 answer

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 .

+9
source

Source: https://habr.com/ru/post/896705/


All Articles