Help prepare for 2025 → Answer 8 simple questions on our Fall Survey
Open Survey
Utility module related to layout.

Summary

Variables

MEASURED_HEIGHT_STATE_SHIFT

MEASURED_HEIGHT_STATE_SHIFT: number
Bits that provide the actual measured size.

MEASURED_SIZE_MASK

MEASURED_SIZE_MASK: number

MEASURED_STATE_MASK

MEASURED_STATE_MASK: number

MEASURED_STATE_TOO_SMALL

MEASURED_STATE_TOO_SMALL: number

UNSPECIFIED

Functions

getDisplayDensity

getDisplayDensity(): number
Gets display density for the current device.
Returns number

getMeasureSpecMode

getMeasureSpecMode(spec: number): number
Gets measure specification mode from a given specification.
Parameter Default Description
spec
number

The measure specification.

Returns number

getMeasureSpecSize

getMeasureSpecSize(spec: number): number
Gets measure specification size from a given specification.
Parameter Default Description
spec
number

The measure specification.

Returns number

getMode

getMode(mode: number): string
Gets layout mode from a given specification as string.
Parameter Default Description
mode
number

The measure specification mode.

Returns string

makeMeasureSpec

makeMeasureSpec(px: number, mode: number): number
Creates measure specification size from size and mode.
Parameter Default Description
px
number

mode
number

The mode component of measure specification.

Returns number

measureNativeView

measureNativeView(
  nativeView: any,
  width: number,
  widthMode: number,
  height: number,
  heightMode: number
): {
  height: number
}
Converts device pixels to device independent pixes and measure the nativeView. Returns the desired size of the nativeView in device pixels.
Parameter Default Description
nativeView
any

the nativeView to measure (UIView or android.view.View)

width
number

the available width

widthMode
number

width mode - UNSPECIFIED, EXACTLY or AT_MOST

height
number

the available hegiht

heightMode
number

height mode - UNSPECIFIED, EXACTLY or AT_MOST

Returns { height: number }

measureSpecToString

measureSpecToString(measureSpec: number): string
Prints user friendly version of the measureSpec.
Parameter Default Description
measureSpec
number

the spec to print

Returns string

round

round(px: number): px
Rounds value used in layout.
Parameter Default Description
px
number

to round.

Returns px

toDeviceIndependentPixels

toDeviceIndependentPixels(value: number): dip
Convert device pixels to device independent pixels - px to dip.
Parameter Default Description
value
number

The pixel to convert.

Returns dip

toDevicePixels

toDevicePixels(value: number): px
Convert device independent pixels to device pixels - dip to px.
Parameter Default Description
value
number

The pixel to convert.

Returns px