View.MeasureSpec


public static class View.MeasureSpec
extends Object

java.lang.Object
   ↳ android.view.View.MeasureSpec


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 constructors

MeasureSpec()

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.

Inherited methods