Class Overview
A MeasureSpec encapsulates the layout requirements passed from parent to child.
Each MeasureSpec represents a requirement for either the width or the height.
A MeasureSpec is comprised of a size and a mode. There are three possible
modes:
- UNSPECIFIED
-
The parent has not imposed any constraint on the child. It can be whatever size
it wants.
- EXACTLY
-
The parent has determined an exact size for the child. The child is going to be
given those bounds regardless of how big it wants to be.
- AT_MOST
-
The child can be as large as it wants up to the specified size.
MeasureSpecs are implemented as ints to reduce object allocation. This class
is provided to pack and unpack the <size, mode> tuple into the int.
Summary
| Constants |
| int |
AT_MOST |
Measure specification mode: The child can be as large as it wants up
to the specified size. |
| int |
EXACTLY |
Measure specification mode: The parent has determined an exact size
for the child. |
| int |
UNSPECIFIED |
Measure specification mode: The parent has not imposed any constraint
on the child. |
| Public Methods |
|
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
String
|
toString(int measureSpec)
Returns a String representation of the specified measure
specification.
|
|
[Expand]
Inherited Methods |
From class java.lang.Object
|
Object
|
clone()
Returns a new instance of the same class as the receiver, whose slots
have been filled in with the values in the slots of the receiver.
|
|
boolean
|
equals(Object o)
Compares the argument to the receiver, and returns true if they represent
the same object using a class specific comparison.
|
|
void
|
finalize()
Called by the virtual machine when there are no longer any (non-weak)
references to the receiver.
|
|
final
Class<? extends Object>
|
getClass()
Returns the unique instance of java.lang.Class which represents the class
of the receiver.
|
|
int
|
hashCode()
Returns an integer hash code for the receiver.
|
|
final
void
|
notify()
Causes one thread which is wait ing on the receiver to be
made ready to run.
|
|
final
void
|
notifyAll()
Causes all threads which are wait ing on the receiver to
be made ready to run.
|
|
String
|
toString()
Returns a string containing a concise, human-readable description of the
receiver.
|
|
final
void
|
wait(long time, int frac)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait(long time)
Causes the thread which sent this message to be made not ready to run
either pending some change in the receiver (as indicated by
notify or notifyAll) or the expiration of
the timeout.
|
|
final
void
|
wait()
Causes the thread which sent this message to be made not ready to run
pending some change in the receiver (as indicated by notify
or notifyAll).
|
|
Constants
public
static
final
int
AT_MOST
Measure specification mode: The child can be as large as it wants up
to the specified size.
Constant Value:
-2147483648
(0x80000000)
public
static
final
int
EXACTLY
Measure specification mode: The parent has determined an exact size
for the child. The child is going to be given those bounds regardless
of how big it wants to be.
Constant Value:
1073741824
(0x40000000)
public
static
final
int
UNSPECIFIED
Measure specification mode: The parent has not imposed any constraint
on the child. It can be whatever size it wants.
Constant Value:
0
(0x00000000)
Public Constructors
public
View.MeasureSpec
()
Public Methods
public
static
int
getMode
(int measureSpec)
Extracts the mode from the supplied measure specification.
Parameters
| measureSpec
| the measure specification to extract the mode from |
public
static
int
getSize
(int measureSpec)
Extracts the size from the supplied measure specification.
Parameters
| measureSpec
| the measure specification to extract the size from |
Returns
- the size in pixels defined in the supplied measure specification
public
static
int
makeMeasureSpec
(int size, int mode)
Creates a measure specification based on the supplied size and mode.
The mode must always be one of the following:
Parameters
| size
| the size of the measure specification |
| mode
| the mode of the measure specification |
Returns
- the measure specification based on size and mode
public
static
String
toString
(int measureSpec)
Returns a String representation of the specified measure
specification.
Parameters
| measureSpec
| the measure specification to convert to a String |
Returns
- a String with the following format: "MeasureSpec: MODE SIZE"