public static class View.MeasureSpec extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
View.MeasureSpec.MeasureSpecMode |
Modifier and Type | Field and Description |
---|---|
static int |
AT_MOST
Measure specification mode: The child can be as large as it wants up
to the specified size.
|
static int |
EXACTLY
Measure specification mode: The parent has determined an exact size
for the child.
|
static int |
UNSPECIFIED
Measure specification mode: The parent has not imposed any constraint
on the child.
|
Constructor and Description |
---|
MeasureSpec() |
Modifier and Type | Method and Description |
---|---|
static int |
getMode(int measureSpec)
Extracts the mode from the supplied measure specification.
|
static int |
getSize(int measureSpec)
Extracts the size from the supplied measure specification.
|
static int |
makeMeasureSpec(int size,
int mode)
Creates a measure specification based on the supplied size and mode.
|
static int |
makeSafeMeasureSpec(int size,
int mode)
Like
makeMeasureSpec(int, int) , but any spec with a mode of UNSPECIFIED
will automatically get a size of 0. |
static String |
toString(int measureSpec)
Returns a String representation of the specified measure
specification.
|
public static final int UNSPECIFIED
public static final int EXACTLY
public static final int AT_MOST
public static int makeMeasureSpec(int size, int mode)
Note: On API level 17 and lower, makeMeasureSpec's
implementation was such that the order of arguments did not matter
and overflow in either value could impact the resulting MeasureSpec.
RelativeLayout
was affected by this bug.
Apps targeting API levels greater than 17 will get the fixed, more strict
behavior.
size
- the size of the measure specificationmode
- the mode of the measure specificationpublic static int makeSafeMeasureSpec(int size, int mode)
makeMeasureSpec(int, int)
, but any spec with a mode of UNSPECIFIED
will automatically get a size of 0. Older apps expect this.public static int getMode(int measureSpec)
measureSpec
- the measure specification to extract the mode fromUNSPECIFIED
,
AT_MOST
or
EXACTLY
public static int getSize(int measureSpec)
measureSpec
- the measure specification to extract the size frompublic static String toString(int measureSpec)
measureSpec
- the measure specification to convert to a String