Google is committed to advancing racial equity for Black communities. See how.

androidx.ui.core

Interfaces

Alignment

An interface to position a point inside a 2D box.

AndroidOwner

Interface to be implemented by Owners able to handle Android View specific functionality.

ContentScale

Represents a rule to apply to scale a source rectangle to be inscribed into a destination

CustomEvent

The base type for all custom events.

CustomEventDispatcher

Defines the interface that is used to dispatch CustomEvents to pointer input nodes across the compose tree.

DrawLayerModifier

A Modifier.Element that makes content draw into a layer, allowing easily changing properties of the drawn contents.

DrawModifier

A Modifier.Element that draws into the space of the layout.

IntrinsicMeasurable

A part of the composition that can be measured.

LayoutCoordinates

A holder of the measured bounds for the layout (MeasureBox).

LayoutIdParentData

Can be implemented by values used as parent data to make them usable as tags.

LayoutModifier

A Modifier.Element that changes how its wrapped content is measured and laid out.

MeasureBlocks

LayoutTagParentData

Measurable

A part of the composition that can be measured.

MeasureResult

Interface holding the size and alignment lines of the measured layout, as well as the children positioning logic.

Modifier

An ordered, immutable collection of modifier elements that decorate or add behavior to Compose UI elements.

OnChildPositionedModifier

A modifier whose onChildPositioned is called with the final LayoutCoordinates of the children Layouts after measuring.

OnPositionedModifier

A modifier whose onPositioned is called with the final LayoutCoordinates of the Layout after measuring.

OwnedLayer

A layer returned by Owner.createLayer to separate drawn content.

Owner

Owner implements the connection to the underlying view system.

ParentDataModifier

A Modifier that provides data to the parent Layout.

PopupPositionProvider

Calculates the position of a Popup on screen.

WithConstraintsScope

Receiver scope being used by the children parameter of WithConstraints

ZIndexModifier

A Modifier.Element that controls the drawing order for the children of the same layout parent.

Classes

AbsoluteAlignment

Represents an absolute positioning of a point inside a 2D box.

AlignmentLine

Defines an offset line that can be used by parent layouts to align and position their children.

AtomicInt

CombinedModifier

A node in a Modifier chain.

Constraints

Immutable constraints used for measuring child Layouts or LayoutModifiers.

ConsumedData

Describes what aspects of, and how much of, a change has been consumed.

ContentDrawScope

Receiver scope for drawing content into a layout, where the content can be drawn between other canvas operations.

FixedScale

ContentScale implementation that always scales the dimension by the provided fixed floating point value

HorizontalAlignmentLine

A horizontal AlignmentLine.

IntrinsicMeasureScope

The receiver scope of a layout's intrinsic measurements lambdas.

LayoutNode

An element in the layout hierarchy, built with compose UI.

Measured

Read-only wrapper over Placeable that exposes the measurement result with no placing ability.

MeasureScope

The receiver scope of a layout's measure lambda.

ModelObserver

Allows for easy model read observation.

ModifierInfo

Used by tooling to examine the modifiers on a LayoutNode.

NativeMatrix

NativeRectF

Placeable

A Placeable corresponds to a child layout that can be positioned by its parent layout.

PointerEvent

Describes a pointer input change event that has occurred at a particular point in time.

PointerId

An ID for a given pointer.

PointerInputChange

Describes a change that has occurred for a particular pointer, as well as how much of the change has been consumed (meaning, used by a node in the UI).

PointerInputData

Data associated with a pointer.

Ref

Value holder general purpose class.

TransformOrigin

A two-dimensional position represented as a fraction of the Layer's width and height

VerticalAlignmentLine

A vertical AlignmentLine.

Type-aliases

IntrinsicMeasureBlock

IntrinsicMeasureBlock2

A function for performing intrinsic measurement.

MeasureBlock

MeasureBlock2

A function for performing layout measurement.

PointerInputHandler

A function used to react to and modify PointerInputChanges.

Annotations

ExperimentalLayoutNodeApi

InternalCoreApi

Enums

Direction

DropDownAlignment

The DropdownPopup is aligned below its parent relative to its left or right corner.

LayoutDirection

A class for defining layout directions.

PointerEventPass

The enumeration of passes where PointerInputChange traverses up and down the UI tree.

Top-level functions summary

AndroidOwner
AndroidOwner(context: Context, lifecycleOwner: LifecycleOwner? = null, viewModelStoreOwner: ViewModelStoreOwner? = null)

Constraints
Constraints(minWidth: Int = 0, maxWidth: Int = Constraints.Infinity, minHeight: Int = 0, maxHeight: Int = Constraints.Infinity)

Create a Constraints.

Unit
DropdownPopup(dropDownAlignment: DropDownAlignment = DropDownAlignment.Start, offset: IntOffset = IntOffset(0, 0), isFocusable: Boolean = false, onDismissRequest: () -> Unit = null, children: () -> Unit)

Opens a popup with the given content.

Unit
Layout(children: () -> Unit, minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock2, minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock2, maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock2, maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock2, modifier: Modifier = Modifier, measureBlock: MeasureBlock2)

Layout is the main core component for layout.

Unit
Layout(children: () -> Unit, minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock, minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock, maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock, maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock, modifier: Modifier = Modifier, measureBlock: MeasureBlock)

Unit
Layout(children: () -> Unit, modifier: Modifier = Modifier, measureBlock: MeasureBlock2)

Layout is the main core component for layout.

Unit
Layout(children: () -> Unit, modifier: Modifier = Modifier, measureBlock: MeasureBlock)

LayoutNode.MeasureBlocks

Default LayoutNode.MeasureBlocks object implementation, providing intrinsic measurements that use the measure block replacing the measure calls with intrinsic measurement calls.

LayoutNode.MeasureBlocks

Unit
MultiMeasureLayout(modifier: Modifier = Modifier, children: () -> Unit, measureBlock: MeasureBlock2)

Unit
Popup(alignment: Alignment = Alignment.TopStart, offset: IntOffset = IntOffset(0, 0), isFocusable: Boolean = false, onDismissRequest: () -> Unit = null, children: () -> Unit)

Opens a popup with the given content.

Unit
Popup(popupPositionProvider: PopupPositionProvider, isFocusable: Boolean = false, onDismissRequest: () -> Unit = null, children: () -> Unit)

TransformOrigin
TransformOrigin(pivotFractionX: Float, pivotFractionY: Float)

Constructs a TransformOrigin from the given fractional values from the Layer's width and height

Unit
WithConstraints(modifier: Modifier = Modifier, children: WithConstraintsScope.() -> Unit)

A composable that defines its own content according to the available space, based on the incoming constraints or the current LayoutDirection.

Boolean
isPopupLayout(view: View, testTag: String? = null)

Returns whether the given view is an underlying decor view of a popup.

Modifier
onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit)

Returns a modifier whose onChildPositioned is called with the final LayoutCoordinates of the children Layouts after measuring.

Modifier
onPositioned(onPositioned: (LayoutCoordinates) -> Unit)

Returns modifier whose onPositioned is called with the final LayoutCoordinates of the Layout after measuring.

Composition
subcomposeInto(container: LayoutNode, parent: CompositionReference? = null, composable: () -> Unit)

Composition
subcomposeInto(container: LayoutNode, recomposer: Recomposer, parent: CompositionReference? = null, composable: () -> Unit)

Top-level properties summary

ProvidableAmbient<AnimationClockObservable>

The default animation clock used for animations when an explicit clock isn't provided.

ProvidableAmbient<Autofill?>

The ambient that can be used to trigger autofill actions.

ProvidableAmbient<AutofillTree>

The ambient that can be used to add AutofillNodes to the autofill tree.

ProvidableAmbient<ClipboardManager>

The ambient to provide communication with platform clipboard service.

ProvidableAmbient<Configuration>

The Android Configuration.

ProvidableAmbient<Context>

Provides a Context that can be used by Android applications.

ProvidableAmbient<Density>

Provides the Density to be used to transform between density-independent pixelunits (DP) and pixel units or scale-independent pixel units (SP) and pixel units.

ProvidableAmbient<HapticFeedback>

The ambient to provide haptic feedback to the user.

ProvidableAmbient<LifecycleOwner>

The ambient containing the current LifecycleOwner.

ProvidableAmbient<TextInputService?>

The ambient to provide communication with platform text input service.

ProvidableAmbient<TextToolbar>

The ambient to provide text-related toolbar.

ProvidableAmbient<UriHandler>

The ambient to provide functionality related to URL, e.

ProvidableAmbient<View>

The ambient containing the current Compose View.

ProvidableAmbient<ViewModelStoreOwner>

The ambient containing the current ViewModelStoreOwner.

Extension functions summary

For android.app.Activity
Composition
Activity.setViewContent(composable: () -> Unit)

Sets the contentView of an activity to a FrameLayout, and composes the contents of the layout with the passed in composable.

For android.graphics.Rect
Rect

Creates a new instance of androidx.ui.geometry.Rect with the same bounds specified in the given android.graphics.Rect

For android.view.ViewGroup
Composition
ViewGroup.setContent(recomposer: Recomposer, parentComposition: CompositionReference? = null, content: () -> Unit)

Composes the given composable into the given view.

Composition
ViewGroup.setContent(content: () -> Unit)

Composes the given composable into the given view.

Composition
ViewGroup.setViewContent(parent: CompositionReference? = null, composable: () -> Unit)

Composes the children of the view with the passed in composable.

For androidx.activity.ComponentActivity
Composition
ComponentActivity.setContent(recomposer: Recomposer = Recomposer.current(), content: () -> Unit)

Composes the given composable into the given activity.

For PointerInputChange
Boolean

True if any aspect of this PointerInputChange has been consumed.

Boolean

True if any of this PointerInputChange's movement has been consumed.

Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen and that change has not been consumed.

Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen, whether or not that change has been consumed.

Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen and that change has not been consumed.

Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen, whether or not that change has been consumed.

PointerInputChange

Consumes all changes associated with the PointerInputChange

PointerInputChange

Consume the up or down change of this PointerInputChange if there is an up or down change to consume.

PointerInputChange

Consumes some portion of the position change of this PointerInputChange.

Offset

The distance that the pointer has moved on the screen minus any distance that has been consumed.

Offset

The distance that the pointer has moved on the screen, ignoring any distance that may have been consumed.

Boolean

True if this PointerInputChange represents a pointer moving on the screen and some of that movement has not been consumed.

Boolean

True if this PointerInputChange represents a pointer moving on the screen ignoring how much of that movement may have been consumed.

For Modifier
Modifier

Clip the content to shape.

Modifier

Clip the content to the bounds of a layer defined at this modifier.

Modifier
Modifier.composed(factory: Modifier.() -> Modifier)

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies.

Modifier
Modifier.drawBehind(onDraw: DrawScope.() -> Unit)

Draw into a Canvas behind the modified content.

Modifier
Modifier.drawLayer(scaleX: Float = 1f, scaleY: Float = 1f, alpha: Float = 1f, translationX: Float = 0f, translationY: Float = 0f, shadowElevation: Float = 0f, rotationX: Float = 0f, rotationY: Float = 0f, rotationZ: Float = 0f, transformOrigin: TransformOrigin = TransformOrigin.Center, shape: Shape = RectangleShape, clip: Boolean = false)

Draw the content into a layer.

Modifier
Modifier.drawOpacity(@FloatRange(0.0, 1.0) opacity: Float)

Draw content with modified opacity (alpha) that may be less than 1.

Modifier
Modifier.drawShadow(elevation: Dp, shape: Shape = RectangleShape, clip: Boolean = elevation > 0.dp, @FloatRange(0.0, 1.0) opacity: Float = 1f)

Creates a DrawLayerModifier that draws the shadow.

Modifier

Creates a DrawModifier that allows the developer to draw before or after the layout's contents.

Modifier

Tag the element with id to identify the element within its parent.

Modifier
Modifier.onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit)

Invoke onChildPositioned with the LayoutCoordinates of each child element after each one is positioned.

Modifier

Invoke onPositioned with the LayoutCoordinates of the element after positioning.

Modifier
Modifier.paint(painter: Painter, sizeToIntrinsics: Boolean = true, alignment: Alignment = Alignment.Center, contentScale: ContentScale = ContentScale.Inside, alpha: Float = DefaultAlpha, colorFilter: ColorFilter? = null)

Paint the content using painter.

Modifier

Tag the element with tag to identify the element within its parent.

Modifier

Applies a tag to allow modified element to be found in tests.

Modifier

Creates a ZIndexModifier that controls the drawing order for the children of the same layout parent.

For Constraints
IntSize

Takes a size and returns the closest size to it that satisfies the constraints.

Int

Takes a height and returns the closest size to it that satisfies the constraints.

Int

Takes a width and returns the closest size to it that satisfies the constraints.

Constraints
Constraints.enforce(otherConstraints: Constraints)

Returns the result of coercing the current constraints in a different set of constraints.

Constraints
Constraints.offset(horizontal: Int = 0, vertical: Int = 0)

Returns the Constraints obtained by offsetting the current instance with the given values.

Boolean

Takes a size and returns whether it satisfies the current constraints.

For LayoutNode
LayoutNode?

Executes selector on every parent of this LayoutNode and returns the closest LayoutNode to return true from selector or null if selector returns false for all ancestors.

For Composer
Modifier

Materialize any instance-specific composed modifiers for applying to a raw tree node.

For AlignmentLine
Int
AlignmentLine.merge(position1: Int, position2: Int)

Merges two values of the current alignment line.

For Rect
Rect

Creates a new instance of android.graphics.Rect with the same bounds specified in the given Rect

RectF

Creates a new instance of android.graphics.RectF with the same bounds specified in the given Rect

Extension properties summary

For android.content.res.Configuration
LayoutDirection

Return the layout direction set by the Locale.

For LayoutCoordinates
PxBounds

Returns the bounding box of the child in the parent's content area, including any clipping done with respect to the parent.

PxBounds

The boundaries of this layout inside the root composable.

PxBounds

The global boundaries of this layout inside.

Offset

The global position of this layout.

Offset

Returns the position of the top-left in the parent's content area or (0, 0) for the root.

Offset

The position of this layout inside the root composable.

For Constraints
Boolean

Whether there is exactly one height value that satisfies the constraints.

Boolean

Whether there is exactly one width value that satisfies the constraints.

Boolean

Whether the area of a component respecting these constraints will definitely be 0.

For Measurable
Any?

Retrieves the tag associated to a composable with the Modifier.layoutId modifier.

Any?

Top-level functions

AndroidOwner

fun AndroidOwner(
    context: Context,
    lifecycleOwner: LifecycleOwner? = null,
    viewModelStoreOwner: ViewModelStoreOwner? = null
): AndroidOwner

This function creates an instance of AndroidOwner

Parameters
context: Context Context to use to create a View
lifecycleOwner: LifecycleOwner? = null Current LifecycleOwner. When it is not provided we will try to get the owner using ViewTreeLifecycleOwner when we will be attached.

Constraints

@Stable fun Constraints(
    minWidth: Int = 0,
    maxWidth: Int = Constraints.Infinity,
    minHeight: Int = 0,
    maxHeight: Int = Constraints.Infinity
): Constraints

Create a Constraints. minWidth and minHeight must be positive and maxWidth and maxHeight must be greater than or equal to minWidth and minHeight, respectively, or Infinity.

@Composable fun DropdownPopup(
    dropDownAlignment: DropDownAlignment = DropDownAlignment.Start,
    offset: IntOffset = IntOffset(0, 0),
    isFocusable: Boolean = false,
    onDismissRequest: () -> Unit = null,
    children: () -> Unit
): Unit

Opens a popup with the given content.

The dropdown popup is positioned below its parent, using the dropDownAlignment and offset. The dropdown popup is visible as long as it is part of the composition hierarchy.

import androidx.ui.core.DropdownPopup
import androidx.ui.foundation.Box
import androidx.ui.foundation.shape.corner.RoundedCornerShape
import androidx.ui.layout.preferredSize

Box(Modifier.preferredSize(400.dp, 200.dp)) {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    // The popup will appear below the parent
    DropdownPopup(dropDownAlignment = DropDownAlignment.Start) {
        // Draw a rectangle shape with rounded corners inside the popup
        Box(
            Modifier.preferredSize(popupWidth, popupHeight),
            shape = RoundedCornerShape(cornerSize),
            backgroundColor = Color.White
        )
    }
}
Parameters
dropDownAlignment: DropDownAlignment = DropDownAlignment.Start The start or end alignment below the parent.
offset: IntOffset = IntOffset(0, 0) An offset from the original aligned position of the popup.
isFocusable: Boolean = false Indicates if the popup can grab the focus.
onDismissRequest: () -> Unit = null Executes when the popup tries to dismiss itself. This happens when the popup is focusable and the user clicks outside.
children: () -> Unit The content to be displayed inside the popup.

Layout

@Composable fun Layout(
    children: () -> Unit,
    minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock2,
    minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock2,
    maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock2,
    maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock2,
    modifier: Modifier = Modifier,
    measureBlock: MeasureBlock2
): Unit

Layout is the main core component for layout. It can be used to measure and position zero or more children.

Intrinsic measurement blocks define the intrinsic sizes of the current layout. These can be queried by the parent in order to understand, in specific cases, what constraints should the layout be measured with:

  • minIntrinsicWidthMeasureBlock defines the minimum width this layout can take, given a specific height, such that the content of the layout will be painted correctly
  • minIntrinsicHeightMeasureBlock defines the minimum height this layout can take, given a specific width, such that the content of the layout will be painted correctly
  • maxIntrinsicWidthMeasureBlock defines the minimum width such that increasing it further will not decrease the minimum intrinsic height
  • maxIntrinsicHeightMeasureBlock defines the minimum height such that increasing it further will not decrease the minimum intrinsic width

For a composable able to define its content according to the incoming constraints, see WithConstraints.

Example usage:

import androidx.ui.core.Constraints
import androidx.ui.core.Layout

// We build a layout that will occupy twice as much space as its children,
// and will position them to be bottom right aligned.
Layout(
    children,
    minIntrinsicWidthMeasureBlock = { measurables, h ->
        // The min intrinsic width of this layout will be twice the largest min intrinsic
        // width of a child. Note that we call minIntrinsicWidth with h / 2 for children,
        // since we should be double the size of the children.
        (measurables.map { it.minIntrinsicWidth(h / 2) }.maxByOrNull { it } ?: 0) * 2
    },
    minIntrinsicHeightMeasureBlock = { measurables, w ->
        (measurables.map { it.minIntrinsicHeight(w / 2) }.maxByOrNull { it } ?: 0) * 2
    },
    maxIntrinsicWidthMeasureBlock = { measurables, h ->
        (measurables.map { it.maxIntrinsicHeight(h / 2) }.maxByOrNull { it } ?: 0) * 2
    },
    maxIntrinsicHeightMeasureBlock = { measurables, w ->
        (measurables.map { it.maxIntrinsicHeight(w / 2) }.maxByOrNull { it } ?: 0) * 2
    }
) { measurables, constraints ->
    // measurables contains one element corresponding to each of our layout children.
    // constraints are the constraints that our parent is currently measuring us with.
    val childConstraints = Constraints(
        minWidth = constraints.minWidth / 2,
        minHeight = constraints.minHeight / 2,
        maxWidth = constraints.maxWidth / 2,
        maxHeight = constraints.maxHeight / 2
    )
    // We measure the children with half our constraints, to ensure we can be double
    // the size of the children.
    val placeables = measurables.map { it.measure(childConstraints) }
    val layoutWidth = (placeables.maxByOrNull { it.width }?.width ?: 0) * 2
    val layoutHeight = (placeables.maxByOrNull { it.height }?.height ?: 0) * 2
    // We call layout to set the size of the current layout and to provide the positioning
    // of the children. The children are placed relative to the current layout place.
    layout(layoutWidth, layoutHeight) {
        placeables.forEach { it.place(layoutWidth - it.width, layoutHeight - it.height) }
    }
}
Parameters
children: () -> Unit The children composable to be laid out.
modifier: Modifier = Modifier Modifiers to be applied to the layout.
minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock2 The minimum intrinsic width of the layout.
minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock2 The minimum intrinsic height of the layout.
maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock2 The maximum intrinsic width of the layout.
maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock2 The maximum intrinsic height of the layout.
measureBlock: MeasureBlock2 The block defining the measurement and positioning of the layout.

Layout

@Composable fun Layout(
    children: () -> Unit,
    minIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock,
    minIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock,
    maxIntrinsicWidthMeasureBlock: IntrinsicMeasureBlock,
    maxIntrinsicHeightMeasureBlock: IntrinsicMeasureBlock,
    modifier: Modifier = Modifier,
    measureBlock: MeasureBlock
): Unit

Deprecated.

Layout

@Composable fun Layout(
    children: () -> Unit,
    modifier: Modifier = Modifier,
    measureBlock: MeasureBlock2
): Unit

Layout is the main core component for layout. It can be used to measure and position zero or more children.

The intrinsic measurements of this layout will be calculated by running the measureBlock, while swapping measure calls with appropriate intrinsic measurements. Note that these provided implementations will not be accurate in all cases - when this happens, the other overload of Layout should be used to provide correct measurements.

For a composable able to define its content according to the incoming constraints, see WithConstraints.

Example usage:

import androidx.ui.core.Constraints
import androidx.ui.core.Layout

// We build a layout that will occupy twice as much space as its children,
// and will position them to be bottom right aligned.
Layout(children) { measurables, constraints ->
    // measurables contains one element corresponding to each of our layout children.
    // constraints are the constraints that our parent is currently measuring us with.
    val childConstraints = Constraints(
        minWidth = constraints.minWidth / 2,
        minHeight = constraints.minHeight / 2,
        maxWidth = constraints.maxWidth / 2,
        maxHeight = constraints.maxHeight / 2
    )
    // We measure the children with half our constraints, to ensure we can be double
    // the size of the children.
    val placeables = measurables.map { it.measure(childConstraints) }
    val layoutWidth = (placeables.maxByOrNull { it.width }?.width ?: 0) * 2
    val layoutHeight = (placeables.maxByOrNull { it.height }?.height ?: 0) * 2
    // We call layout to set the size of the current layout and to provide the positioning
    // of the children. The children are placed relative to the current layout place.
    layout(layoutWidth, layoutHeight) {
        placeables.forEach { it.place(layoutWidth - it.width, layoutHeight - it.height) }
    }
}
Parameters
children: () -> Unit The children composable to be laid out.
modifier: Modifier = Modifier Modifiers to be applied to the layout.
measureBlock: MeasureBlock2 The block defining the measurement and positioning of the layout.

Layout

@Composable fun Layout(
    children: () -> Unit,
    modifier: Modifier = Modifier,
    measureBlock: MeasureBlock
): Unit

Deprecated.

MeasuringIntrinsicsMeasureBlocks

fun MeasuringIntrinsicsMeasureBlocks(measureBlock: MeasureBlock2): LayoutNode.MeasureBlocks

Default LayoutNode.MeasureBlocks object implementation, providing intrinsic measurements that use the measure block replacing the measure calls with intrinsic measurement calls.

MeasuringIntrinsicsMeasureBlocks

fun MeasuringIntrinsicsMeasureBlocks(measureBlock: MeasureBlock): LayoutNode.MeasureBlocks

Deprecated.

MultiMeasureLayout

@Composable fun MultiMeasureLayout(
    modifier: Modifier = Modifier,
    children: () -> Unit,
    measureBlock: MeasureBlock2
): Unit

Deprecated.

@Composable fun Popup(
    alignment: Alignment = Alignment.TopStart,
    offset: IntOffset = IntOffset(0, 0),
    isFocusable: Boolean = false,
    onDismissRequest: () -> Unit = null,
    children: () -> Unit
): Unit

Opens a popup with the given content.

The popup is positioned relative to its parent, using the alignment and offset. The popup is visible as long as it is part of the composition hierarchy.

import androidx.ui.core.Popup
import androidx.ui.foundation.Box
import androidx.ui.foundation.shape.corner.RoundedCornerShape
import androidx.ui.layout.preferredSize

Box {
    val popupWidth = 200.dp
    val popupHeight = 50.dp
    val cornerSize = 16.dp

    Popup(alignment = Alignment.Center) {
        // Draw a rectangle shape with rounded corners inside the popup
        Box(
            Modifier.preferredSize(popupWidth, popupHeight),
            shape = RoundedCornerShape(cornerSize),
            backgroundColor = Color.White
        )
    }
}
Parameters
alignment: Alignment = Alignment.TopStart The alignment relative to the parent.
offset: IntOffset = IntOffset(0, 0) An offset from the original aligned position of the popup. Offset respects the Ltr/Rtl context, thus in Ltr it will be added to the original aligned position and in Rtl it will be subtracted from it.
isFocusable: Boolean = false Indicates if the popup can grab the focus.
onDismissRequest: () -> Unit = null Executes when the popup tries to dismiss itself. This happens when the popup is focusable and the user clicks outside.
children: () -> Unit The content to be displayed inside the popup.
@Composable fun Popup(
    popupPositionProvider: PopupPositionProvider,
    isFocusable: Boolean = false,
    onDismissRequest: () -> Unit = null,
    children: () -> Unit
): Unit

TransformOrigin

inline fun TransformOrigin(
    pivotFractionX: Float,
    pivotFractionY: Float
): TransformOrigin

Constructs a TransformOrigin from the given fractional values from the Layer's width and height

WithConstraints

@Composable fun WithConstraints(
    modifier: Modifier = Modifier,
    children: WithConstraintsScope.() -> Unit
): Unit

A composable that defines its own content according to the available space, based on the incoming constraints or the current LayoutDirection. Example usage:

import androidx.ui.core.WithConstraints
import androidx.ui.foundation.Box
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize

WithConstraints {
    val rectangleHeight = 100.dp
    if (maxHeight < rectangleHeight * 2) {
        Box(Modifier.preferredSize(50.dp, rectangleHeight), backgroundColor = Color.Blue)
    } else {
        Column {
            Box(Modifier.preferredSize(50.dp, rectangleHeight), backgroundColor = Color.Blue)
            Box(Modifier.preferredSize(50.dp, rectangleHeight), backgroundColor = Color.Gray)
        }
    }
}
The composable will compose the given children, and will position the resulting layout composablesin a parent Layout. This layout will be as small as possible such that it can fit itschildren. If the composition yields multiple layout children, these will be all placed at thetop left of the WithConstraints, so consider wrapping them in an additional commonparent if different positioning is preferred.
Parameters
modifier: Modifier = Modifier Modifier to be applied to the introduced layout.

isPopupLayout

@TestOnly fun isPopupLayout(
    view: View,
    testTag: String? = null
): Boolean

Returns whether the given view is an underlying decor view of a popup. If the given testTag is supplied it also verifies that the popup has such tag assigned.

Parameters
view: View View to verify.
testTag: String? = null If provided, tests that the given tag in defined on the popup.

onChildPositioned

fun onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit): Modifier

Deprecated.

Returns a modifier whose onChildPositioned is called with the final LayoutCoordinates of the children Layouts after measuring. Note that it will be called after a composition when the coordinates are finalized.

Usage example:

import androidx.ui.core.onChildPositioned
import androidx.ui.foundation.Box
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize

Column(Modifier.onChildPositioned { coordinates ->
    // This will be the size of the child SizedRectangle.
    coordinates.size
    // The position of the SizedRectangle relative to the application window.
    coordinates.globalPosition
    // The position of the SizedRectangle relative to the Compose root.
    coordinates.positionInRoot
    // These will be the alignment lines provided to the layout (empty for SizedRectangle)
    coordinates.providedAlignmentLines
    // This will a LayoutCoordinates instance corresponding to the Column.
    coordinates.parentCoordinates
}) {
    Box(Modifier.preferredSize(20.dp), backgroundColor = Color.Green)
}

onPositioned

fun onPositioned(onPositioned: (LayoutCoordinates) -> Unit): Modifier

Deprecated.

Returns modifier whose onPositioned is called with the final LayoutCoordinates of the Layout after measuring. Note that it will be called after a composition when the coordinates are finalized.

Usage example:

import androidx.ui.core.onPositioned
import androidx.ui.foundation.Box
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize

Column(Modifier.onPositioned { coordinates ->
    // This will be the size of the Column.
    coordinates.size
    // The position of the Column relative to the application window.
    coordinates.globalPosition
    // The position of the Column relative to the Compose root.
    coordinates.positionInRoot
    // These will be the alignment lines provided to the layout (empty here for Column).
    coordinates.providedAlignmentLines
    // This will a LayoutCoordinates instance corresponding to the parent of Column.
    coordinates.parentCoordinates
}) {
    Box(Modifier.preferredSize(20.dp), backgroundColor = Color.Green)
    Box(Modifier.preferredSize(20.dp), backgroundColor = Color.Blue)
}

subcomposeInto

@MainThread fun subcomposeInto(
    container: LayoutNode,
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Deprecated.

subcomposeInto

@MainThread fun subcomposeInto(
    container: LayoutNode,
    recomposer: Recomposer,
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Top-level properties

AnimationClockAmbient

val AnimationClockAmbient: ProvidableAmbient<AnimationClockObservable>

The default animation clock used for animations when an explicit clock isn't provided.

AutofillAmbient

val AutofillAmbient: ProvidableAmbient<Autofill?>

The ambient that can be used to trigger autofill actions. Eg. Autofill.requestAutofillForNode.

AutofillTreeAmbient

val AutofillTreeAmbient: ProvidableAmbient<AutofillTree>

The ambient that can be used to add AutofillNodes to the autofill tree. The AutofillTree is a temporary data structure that will be replaced by Autofill Semantics (b/138604305).

ClipboardManagerAmbient

val ClipboardManagerAmbient: ProvidableAmbient<ClipboardManager>

The ambient to provide communication with platform clipboard service.

ConfigurationAmbient

val ConfigurationAmbient: ProvidableAmbient<Configuration>

The Android Configuration. The Configuration is useful for determining how to organize the UI.

ContextAmbient

val ContextAmbient: ProvidableAmbient<Context>

Provides a Context that can be used by Android applications.

DensityAmbient

val DensityAmbient: ProvidableAmbient<Density>

Provides the Density to be used to transform between density-independent pixelunits (DP) and pixel units or scale-independent pixel units (SP) and pixel units. This is typically used when a DP is provided and it must be converted in the body of Layout or DrawModifier.

HapticFeedBackAmbient

val HapticFeedBackAmbient: ProvidableAmbient<HapticFeedback>

The ambient to provide haptic feedback to the user.

LifecycleOwnerAmbient

val LifecycleOwnerAmbient: ProvidableAmbient<LifecycleOwner>

The ambient containing the current LifecycleOwner.

TextInputServiceAmbient

val TextInputServiceAmbient: ProvidableAmbient<TextInputService?>

The ambient to provide communication with platform text input service.

TextToolbarAmbient

val TextToolbarAmbient: ProvidableAmbient<TextToolbar>

The ambient to provide text-related toolbar.

UriHandlerAmbient

val UriHandlerAmbient: ProvidableAmbient<UriHandler>

The ambient to provide functionality related to URL, e.g. open URI.

ViewAmbient

val ViewAmbient: ProvidableAmbient<View>

The ambient containing the current Compose View.

ViewModelStoreOwnerAmbient

val ViewModelStoreOwnerAmbient: ProvidableAmbient<ViewModelStoreOwner>

The ambient containing the current ViewModelStoreOwner.

Extension functions

anyChangeConsumed

fun PointerInputChange.anyChangeConsumed(): Boolean

True if any aspect of this PointerInputChange has been consumed.

anyPositionChangeConsumed

fun PointerInputChange.anyPositionChangeConsumed(): Boolean

True if any of this PointerInputChange's movement has been consumed.

changedToDown

fun PointerInputChange.changedToDown(): Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen and that change has not been consumed.

changedToDownIgnoreConsumed

fun PointerInputChange.changedToDownIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer coming in contact with the screen, whether or not that change has been consumed.

changedToUp

fun PointerInputChange.changedToUp(): Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen and that change has not been consumed.

changedToUpIgnoreConsumed

fun PointerInputChange.changedToUpIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer breaking contact with the screen, whether or not that change has been consumed.

clip

@Stable fun Modifier.clip(shape: Shape): Modifier

Clip the content to shape.

Parameters
shape: Shape the content will be clipped to this Shape.

clipToBounds

@Stable fun Modifier.clipToBounds(): Modifier

Clip the content to the bounds of a layer defined at this modifier.

composed

fun Modifier.composed(factory: Modifier.() -> Modifier): Modifier

Declare a just-in-time composition of a Modifier that will be composed for each element it modifies. composed may be used to implement stateful modifiers that have instance-specific state for each modified element, allowing the same Modifier instance to be safely reused for multiple elements while maintaining element-specific state.

materialize must be called to create instance-specific modifiers if you are directly applying a Modifier to an element tree node.

constrain

@Stable fun Constraints.constrain(size: IntSize): IntSize

Takes a size and returns the closest size to it that satisfies the constraints.

constrainHeight

@Stable fun Constraints.constrainHeight(height: Int): Int

Takes a height and returns the closest size to it that satisfies the constraints.

constrainWidth

@Stable fun Constraints.constrainWidth(width: Int): Int

Takes a width and returns the closest size to it that satisfies the constraints.

consumeAllChanges

fun PointerInputChange.consumeAllChanges(): PointerInputChange

Consumes all changes associated with the PointerInputChange

Note: This function creates a modified copy of this PointerInputChange

consumeDownChange

fun PointerInputChange.consumeDownChange(): PointerInputChange

Consume the up or down change of this PointerInputChange if there is an up or down change to consume.

Note: This function creates a modified copy of this PointerInputChange.

consumePositionChange

fun PointerInputChange.consumePositionChange(
    consumedDx: Float,
    consumedDy: Float
): PointerInputChange

Consumes some portion of the position change of this PointerInputChange.

Note: This function creates a modified copy of this PointerInputChange

Parameters
consumedDx: Float The amount of position change on the x axis to consume.
consumedDy: Float The amount of position change on the y axis to consume.

drawBehind

fun Modifier.drawBehind(onDraw: DrawScope.() -> Unit): Modifier

Draw into a Canvas behind the modified content.

drawLayer

@Stable fun Modifier.drawLayer(
    scaleX: Float = 1f,
    scaleY: Float = 1f,
    alpha: Float = 1f,
    translationX: Float = 0f,
    translationY: Float = 0f,
    shadowElevation: Float = 0f,
    rotationX: Float = 0f,
    rotationY: Float = 0f,
    rotationZ: Float = 0f,
    transformOrigin: TransformOrigin = TransformOrigin.Center,
    shape: Shape = RectangleShape,
    clip: Boolean = false
): Modifier

Draw the content into a layer. This permits applying special effects and transformations:

import androidx.ui.core.drawLayer
import androidx.ui.foundation.Text

Text("Hello World", Modifier.drawLayer(alpha = 0.5f, clip = true))
Parameters
scaleX: Float = 1f DrawLayerModifier.scaleX
scaleY: Float = 1f DrawLayerModifier.scaleY
alpha: Float = 1f DrawLayerModifier.alpha
shadowElevation: Float = 0f DrawLayerModifier.shadowElevation
rotationX: Float = 0f DrawLayerModifier.rotationX
rotationY: Float = 0f DrawLayerModifier.rotationY
rotationZ: Float = 0f DrawLayerModifier.rotationZ
shape: Shape = RectangleShape DrawLayerModifier.shape
clip: Boolean = false DrawLayerModifier.clip

drawOpacity

@Stable fun Modifier.drawOpacity(@FloatRange(0.0, 1.0) opacity: Float): Modifier

Draw content with modified opacity (alpha) that may be less than 1.

Example usage:

import androidx.ui.core.drawOpacity
import androidx.ui.foundation.Box
import androidx.ui.layout.preferredSize

Box(Modifier.preferredSize(100.dp).drawOpacity(opacity = 0.5f), backgroundColor = Color.Red)
Parameters
opacity: Float the fraction of children's alpha value.

drawShadow

@Stable fun Modifier.drawShadow(
    elevation: Dp,
    shape: Shape = RectangleShape,
    clip: Boolean = elevation > 0.dp,
    @FloatRange(0.0, 1.0) opacity: Float = 1f
): Modifier

Creates a DrawLayerModifier that draws the shadow. The elevation defines the visual depth of the physical object. The physical object has a shape specified by shape.

Note that elevation is only affecting the shadow size and doesn't change the drawing order. Use zIndex modifier if you want to draw the elements with larger elevation after all the elements with a smaller one.

Example usage:

import androidx.ui.core.drawShadow
import androidx.ui.foundation.Box
import androidx.ui.layout.preferredSize

Box(
    Modifier.drawShadow(12.dp, RectangleShape)
        .preferredSize(100.dp, 100.dp)
)
Parameters
elevation: Dp The elevation for the shadow in pixels
shape: Shape = RectangleShape Defines a shape of the physical object
clip: Boolean = elevation > 0.dp When active, the content drawing clips to the shape.
opacity: Float = 1f The opacity of the layer, including the shadow.

drawWithContent

fun Modifier.drawWithContent(onDraw: ContentDrawScope.() -> Unit): Modifier

Creates a DrawModifier that allows the developer to draw before or after the layout's contents. It also allows the modifier to adjust the layout's canvas.

enforce

@Stable fun Constraints.enforce(otherConstraints: Constraints): Constraints

Returns the result of coercing the current constraints in a different set of constraints.

findClosestParentNode

fun LayoutNode.findClosestParentNode(selector: (LayoutNode) -> Boolean): LayoutNode?

Executes selector on every parent of this LayoutNode and returns the closest LayoutNode to return true from selector or null if selector returns false for all ancestors.

layoutId

@Stable fun Modifier.layoutId(id: Any): Modifier

Tag the element with id to identify the element within its parent.

Example usage:

import androidx.ui.core.Layout
import androidx.ui.core.layoutId
import androidx.ui.foundation.Box

Layout({
    // Here the Containers are only needed to apply the modifiers. You could use the
    // modifier on header and footer directly if they are composables accepting modifiers.
    Box(Modifier.layoutId("header"), children = header)
    Box(Modifier.layoutId("footer"), children = footer)
}) { measurables, constraints ->
    val placeables = measurables.map { measurable ->
        when (measurable.id) {
            // You should use appropriate constraints. Here we measure with dummy constraints.
            "header" -> measurable.measure(Constraints.fixed(100, 100))
            "footer" -> measurable.measure(constraints)
            else -> error("Unexpected tag")
        }
    }
    // Size should be derived from children measured sizes on placeables,
    // but this is simplified for the purposes of the example.
    layout(100, 100) {
        placeables.forEach { it.place(0, 0) }
    }
}

materialize

fun Composer<*>.materialize(modifier: Modifier): Modifier

Materialize any instance-specific composed modifiers for applying to a raw tree node. Call right before setting the returned modifier on an emitted node. You almost certainly do not need to call this function directly.

merge

fun AlignmentLine.merge(
    position1: Int,
    position2: Int
): Int

Merges two values of the current alignment line.

offset

@Stable fun Constraints.offset(
    horizontal: Int = 0,
    vertical: Int = 0
): Constraints

Returns the Constraints obtained by offsetting the current instance with the given values.

onChildPositioned

fun Modifier.onChildPositioned(onChildPositioned: (LayoutCoordinates) -> Unit): Modifier

Invoke onChildPositioned with the LayoutCoordinates of each child element after each one is positioned. Note that it will be called after a composition when the coordinates are finalized.

Usage example:

import androidx.ui.core.onChildPositioned
import androidx.ui.foundation.Box
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize

Column(Modifier.onChildPositioned { coordinates ->
    // This will be the size of the child SizedRectangle.
    coordinates.size
    // The position of the SizedRectangle relative to the application window.
    coordinates.globalPosition
    // The position of the SizedRectangle relative to the Compose root.
    coordinates.positionInRoot
    // These will be the alignment lines provided to the layout (empty for SizedRectangle)
    coordinates.providedAlignmentLines
    // This will a LayoutCoordinates instance corresponding to the Column.
    coordinates.parentCoordinates
}) {
    Box(Modifier.preferredSize(20.dp), backgroundColor = Color.Green)
}

onPositioned

fun Modifier.onPositioned(onPositioned: (LayoutCoordinates) -> Unit): Modifier

Invoke onPositioned with the LayoutCoordinates of the element after positioning. Note that it will be called after a composition when the coordinates are finalized.

Usage example:

import androidx.ui.core.onPositioned
import androidx.ui.foundation.Box
import androidx.ui.layout.Column
import androidx.ui.layout.preferredSize

Column(Modifier.onPositioned { coordinates ->
    // This will be the size of the Column.
    coordinates.size
    // The position of the Column relative to the application window.
    coordinates.globalPosition
    // The position of the Column relative to the Compose root.
    coordinates.positionInRoot
    // These will be the alignment lines provided to the layout (empty here for Column).
    coordinates.providedAlignmentLines
    // This will a LayoutCoordinates instance corresponding to the parent of Column.
    coordinates.parentCoordinates
}) {
    Box(Modifier.preferredSize(20.dp), backgroundColor = Color.Green)
    Box(Modifier.preferredSize(20.dp), backgroundColor = Color.Blue)
}

paint

fun Modifier.paint(
    painter: Painter,
    sizeToIntrinsics: Boolean = true,
    alignment: Alignment = Alignment.Center,
    contentScale: ContentScale = ContentScale.Inside,
    alpha: Float = DefaultAlpha,
    colorFilter: ColorFilter? = null
): Modifier

Paint the content using painter.

import androidx.ui.core.paint
import androidx.ui.foundation.Box
import androidx.ui.foundation.drawBackground
import androidx.ui.geometry.Size
import androidx.ui.layout.padding

class CustomPainter : Painter() {

    override val intrinsicSize: Size
        get() = Size(300.0f, 300.0f)

    override fun DrawScope.onDraw() {
        drawCircle(
            center = center,
            radius = size.minDimension / 2.0f,
            color = Color.Red
        )
    }
}

Box(
    modifier =
        Modifier.drawBackground(Color.Gray)
            .padding(30.dp)
            .drawBackground(Color.Yellow)
            .paint(CustomPainter())
) { /** intentionally empty **/ }
Parameters
sizeToIntrinsics: Boolean = true true to size the element relative to Painter.intrinsicSize
alignment: Alignment = Alignment.Center specifies alignment of the painter relative to content
contentScale: ContentScale = ContentScale.Inside strategy for scaling painter if its size does not match the content size
alpha: Float = DefaultAlpha opacity of painter
colorFilter: ColorFilter? = null optional ColorFilter to apply to painter

positionChange

fun PointerInputChange.positionChange(): Offset

The distance that the pointer has moved on the screen minus any distance that has been consumed.

positionChangeIgnoreConsumed

fun PointerInputChange.positionChangeIgnoreConsumed(): Offset

The distance that the pointer has moved on the screen, ignoring any distance that may have been consumed.

positionChanged

fun PointerInputChange.positionChanged(): Boolean

True if this PointerInputChange represents a pointer moving on the screen and some of that movement has not been consumed.

positionChangedIgnoreConsumed

fun PointerInputChange.positionChangedIgnoreConsumed(): Boolean

True if this PointerInputChange represents a pointer moving on the screen ignoring how much of that movement may have been consumed.

satisfiedBy

@Stable fun Constraints.satisfiedBy(size: IntSize): Boolean

Takes a size and returns whether it satisfies the current constraints.

setContent

fun ViewGroup.setContent(
    recomposer: Recomposer,
    parentComposition: CompositionReference? = null,
    content: () -> Unit
): Composition

Composes the given composable into the given view.

The new composition can be logically "linked" to an existing one, by providing a non-null parentComposition. This will ensure that invalidations and ambients will flow through the two compositions as if they were not separate.

Note that this ViewGroup should have an unique id for the saved instance state mechanism to be able to save and restore the values used within the composition. See View.setId.

Parameters
recomposer: Recomposer The Recomposer to coordinate scheduling of composition updates.
parentComposition: CompositionReference? = null The parent composition reference, if applicable.
content: () -> Unit Composable that will be the content of the view.

setContent

fun ViewGroup.setContent(content: () -> Unit): Composition

Deprecated.

Composes the given composable into the given view.

Note that this ViewGroup should have an unique id for the saved instance state mechanism to be able to save and restore the values used within the composition. See View.setId.

Parameters
content: () -> Unit Composable that will be the content of the view.

setContent

fun ComponentActivity.setContent(
    recomposer: Recomposer = Recomposer.current(),
    content: () -> Unit
): Composition

Composes the given composable into the given activity. The content will become the root view of the given activity.

Composition.dispose is called automatically when the Activity is destroyed.

Parameters
recomposer: Recomposer = Recomposer.current() The Recomposer to coordinate scheduling of composition updates
content: () -> Unit A @Composable function declaring the UI contents

setViewContent

fun Activity.setViewContent(composable: () -> Unit): Composition

Sets the contentView of an activity to a FrameLayout, and composes the contents of the layout with the passed in composable.

setViewContent

fun ViewGroup.setViewContent(
    parent: CompositionReference? = null,
    composable: () -> Unit
): Composition

Composes the children of the view with the passed in composable.

tag

@Stable fun Modifier.tag(tag: Any): Modifier

Deprecated.

Tag the element with tag to identify the element within its parent.

testTag

@Stable fun Modifier.testTag(tag: String): Modifier

Applies a tag to allow modified element to be found in tests.

This is a convenience method for a semantics that sets SemanticsPropertyReceiver.testTag.

toAndroidRect

fun Rect.toAndroidRect(): Rect

Creates a new instance of android.graphics.Rect with the same bounds specified in the given Rect

toAndroidRectF

fun Rect.toAndroidRectF(): RectF

Creates a new instance of android.graphics.RectF with the same bounds specified in the given Rect

toComposeRect

fun Rect.toComposeRect(): Rect

Creates a new instance of androidx.ui.geometry.Rect with the same bounds specified in the given android.graphics.Rect

zIndex

@Stable fun Modifier.zIndex(zIndex: Float): Modifier

Creates a ZIndexModifier that controls the drawing order for the children of the same layout parent. A child with larger zIndex will be drawn after all the children with smaller zIndex. When children have the same zIndex the original order in which the items were added into the parent layout is applied. Note that if there would be multiple ZIndexModifier modifiers applied for the same layout only the first one in the modifiers chain will be used. If no ZIndexModifiers applied for the layout then zIndex for this Layout is 0.

import androidx.ui.core.zIndex
import androidx.ui.foundation.Text
import androidx.ui.layout.Stack

Stack {
    Text("Drawn second", Modifier.zIndex(1f))
    Text("Drawn first")
}

Extension properties

boundsInParent

val LayoutCoordinates.boundsInParent: PxBounds

Returns the bounding box of the child in the parent's content area, including any clipping done with respect to the parent. For the root, the bounds is positioned at (0, 0) and sized to the size of the root.

boundsInRoot

val LayoutCoordinates.boundsInRoot: PxBounds

The boundaries of this layout inside the root composable.

globalBounds

val LayoutCoordinates.globalBounds: PxBounds

The global boundaries of this layout inside.

globalPosition

inline val LayoutCoordinates.globalPosition: Offset

The global position of this layout.

hasFixedHeight

@Stable val Constraints.hasFixedHeight: Boolean

Whether there is exactly one height value that satisfies the constraints.

hasFixedWidth

@Stable val Constraints.hasFixedWidth: Boolean

Whether there is exactly one width value that satisfies the constraints.

id

val Measurable.id: Any?

Retrieves the tag associated to a composable with the Modifier.layoutId modifier. For a parent data value to be returned by this property when not using the Modifier.layoutId modifier, the parent data value should implement the LayoutIdParentData interface.

Example usage:

import androidx.ui.core.Layout
import androidx.ui.core.layoutId
import androidx.ui.foundation.Box

Layout({
    // Here the Containers are only needed to apply the modifiers. You could use the
    // modifier on header and footer directly if they are composables accepting modifiers.
    Box(Modifier.layoutId("header"), children = header)
    Box(Modifier.layoutId("footer"), children = footer)
}) { measurables, constraints ->
    val placeables = measurables.map { measurable ->
        when (measurable.id) {
            // You should use appropriate constraints. Here we measure with dummy constraints.
            "header" -> measurable.measure(Constraints.fixed(100, 100))
            "footer" -> measurable.measure(constraints)
            else -> error("Unexpected tag")
        }
    }
    // Size should be derived from children measured sizes on placeables,
    // but this is simplified for the purposes of the example.
    layout(100, 100) {
        placeables.forEach { it.place(0, 0) }
    }
}

isZero

@Stable val Constraints.isZero: Boolean

Whether the area of a component respecting these constraints will definitely be 0. This is true when at least one of maxWidth and maxHeight are 0.

localeLayoutDirection

val Configuration.localeLayoutDirection: LayoutDirection

Return the layout direction set by the Locale.

A convenience getter that translates Configuration.getLayoutDirection result into LayoutDirection instance.

positionInParent

val LayoutCoordinates.positionInParent: Offset

Returns the position of the top-left in the parent's content area or (0, 0) for the root.

positionInRoot

inline val LayoutCoordinates.positionInRoot: Offset

The position of this layout inside the root composable.

tag

val Measurable.tag: Any?

Deprecated.