Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

view

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.

like image 571
CoDe Avatar asked Sep 06 '11 11:09

CoDe


1 Answers

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.

like image 189
marc1s Avatar answered Oct 30 '22 18:10

marc1s