The Developer Preview for Android 11 is now available; test it out and share your feedback.

LayoutNode

class LayoutNode : ComponentNode, Measurable
kotlin.Any
   ↳ androidx.ui.core.ComponentNode
   ↳ androidx.ui.core.LayoutNode

Backing node for Layout component.

Measuring a LayoutNode as a Measurable will measure the node's content as adjusted by modifier.

Summary

Nested classes

abstract

abstract

abstract

Public constructors

Backing node for Layout component.

Public methods

Unit
attach(owner: Owner)

Set the Owner of this ComponentNode.

Unit

Remove the ComponentNode from the Owner.

Unit
draw(canvas: Canvas, density: Density)

IntPx?

Returns the alignment line value for a given alignment line without affecting whether the flag for whether the alignment line was read.

Unit
ignoreModelReads(block: () -> Unit)

Execute your code within the block if you want some code to not be observed for the model reads even if you are currently inside some observed scope like measuring.

Unit

IntPx

Calculates the smallest height beyond which increasing the height never decreases the width.

IntPx

Calculates the smallest width beyond which increasing the width never decreases the height.

Placeable
measure(constraints: Constraints)

Resizes the layout based on constraints, returning a Placeable layout that has its new size.

IntPx

Calculates the minimum height that the layout can be such that the content of the layout will be painted correctly.

IntPx

Calculates the minimum width that the layout can be such that the content of the layout will be painted correctly.

Unit

Used to request a new draw pass from the owner.

Unit
place(x: IntPx, y: IntPx)

Unit

Used to request a new measurement + layout pass from the owner.

String

Inherited functions

Inherited extension functions

From androidx.ui.core
Unit

Inserts a child ComponentNode at a last index.

ComponentNode?

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

LayoutNode?

Executes block on first level of LayoutNode descendants of this ComponentNode and returns the last LayoutNode to return true from block.

Boolean

Returns true if this ComponentNode has no descendant LayoutNodes.

Boolean

Returns true if this ComponentNode currently has an ComponentNode.owner.

Owner

Returns ComponentNode.owner or throws if it is null.

Unit

Executes block on first level of LayoutNode descendants of this ComponentNode.

From androidx.compose
operator T

IMPORTANT: This global operator is TEMPORARY, and should be removed whenever an answer for contextual composers is reached.

Properties

Boolean

true when the parent's size depends on this LayoutNode's size

Constraints

The constraints used the last time layout was called.

LayoutNode?

Protected method to find the parent's layout node.

LayoutCoordinates

Coordinates of just the contents of the LayoutNode, after being affected by all modifiers.

IntPx

The measured height of this layout and all of its modifiers.

Boolean

true when inside layout

Boolean

true when inside measure

Boolean

Whether or not this has been placed in the hierarchy.

List<LayoutNode>

All first level LayoutNode descendants.

LayoutNode.MeasureBlocks

Blocks that define the measurement and intrinsic measurement of the layout.

MeasureScope

The scope used to run the MeasureBlocks.measure.

Modifier

The Modifier currently applied to this node.

Boolean

true when the layout has been measured or dirtied because the layout lambda accessed a model that has been dirtied.

Boolean

true when the layout has been dirtied by requestRemeasure.

(Owner) -> Unit

Callback to be executed whenever the LayoutNode is attached to a new Owner.

(Owner) -> Unit

Callback to be executed whenever the LayoutNode is detached from an Owner.

Any?

Data provided by the ParentData

LayoutNode?

This is the LayoutNode ancestor that contains this LayoutNode.

Boolean

true when the current node is positioned during the measure pass, since it needs to compute alignment lines.

Ref<LayoutNode>?

Implementation oddity around composition; used to capture a reference to this LayoutNode when composed.

IntPx

The measured width of this layout and all of its modifiers.

Inherited properties

Inherited extension properties

From androidx.ui.core
Any?

Retrieves the tag associated to a composable with the LayoutTag modifier.

Public constructors

<init>

LayoutNode()

Backing node for Layout component.

Measuring a LayoutNode as a Measurable will measure the node's content as adjusted by modifier.

Public methods

attach

fun attach(owner: Owner): Unit

Set the Owner of this ComponentNode. This ComponentNode must not already be attached. owner must match its parent.owner.

detach

fun detach(): Unit

Remove the ComponentNode from the Owner. The owner must not be null before this call and its parent's owner must be null before calling this. This will also detach all children. After executing, the owner will be null.

draw

fun draw(
    canvas: Canvas,
    density: Density
): Unit

getAlignmentLine

fun getAlignmentLine(line: AlignmentLine): IntPx?

Returns the alignment line value for a given alignment line without affecting whether the flag for whether the alignment line was read.

ignoreModelReads

fun ignoreModelReads(block: () -> Unit): Unit

Execute your code within the block if you want some code to not be observed for the model reads even if you are currently inside some observed scope like measuring.

layout

fun layout(): Unit

maxIntrinsicHeight

fun maxIntrinsicHeight(width: IntPx): IntPx

Calculates the smallest height beyond which increasing the height never decreases the width.

maxIntrinsicWidth

fun maxIntrinsicWidth(height: IntPx): IntPx

Calculates the smallest width beyond which increasing the width never decreases the height.

measure

fun measure(constraints: Constraints): Placeable

Resizes the layout based on constraints, returning a Placeable layout that has its new size. A Measurable can only be measured once inside a layout pass.

minIntrinsicHeight

fun minIntrinsicHeight(width: IntPx): IntPx

Calculates the minimum height that the layout can be such that the content of the layout will be painted correctly.

minIntrinsicWidth

fun minIntrinsicWidth(height: IntPx): IntPx

Calculates the minimum width that the layout can be such that the content of the layout will be painted correctly.

onInvalidate

fun onInvalidate(): Unit

Used to request a new draw pass from the owner.

place

fun place(
    x: IntPx,
    y: IntPx
): Unit

requestRemeasure

fun requestRemeasure(): Unit

Used to request a new measurement + layout pass from the owner.

toString

fun toString(): String

Properties

affectsParentSize

var affectsParentSize: Boolean

true when the parent's size depends on this LayoutNode's size

constraints

var constraints: Constraints

The constraints used the last time layout was called.

containingLayoutNode

protected val containingLayoutNode: LayoutNode?

Protected method to find the parent's layout node. LayoutNode returns itself, but all other ComponentNodes return the parent's containingLayoutNode.

coordinates

val coordinates: LayoutCoordinates

Coordinates of just the contents of the LayoutNode, after being affected by all modifiers.

height

val height: IntPx

The measured height of this layout and all of its modifiers. Shortcut for size.height.

isLayingOut

var isLayingOut: Boolean

true when inside layout

isMeasuring

var isMeasuring: Boolean

true when inside measure

isPlaced

var isPlaced: Boolean

Whether or not this has been placed in the hierarchy.

layoutChildren

val layoutChildren: List<LayoutNode>

All first level LayoutNode descendants. All LayoutNodes in the List will have this as parentLayoutNode.

measureBlocks

var measureBlocks: LayoutNode.MeasureBlocks

Blocks that define the measurement and intrinsic measurement of the layout.

measureScope

val measureScope: MeasureScope

The scope used to run the MeasureBlocks.measure.

modifier

var modifier: Modifier

The Modifier currently applied to this node.

needsRelayout

var needsRelayout: Boolean

true when the layout has been measured or dirtied because the layout lambda accessed a model that has been dirtied.

needsRemeasure

var needsRemeasure: Boolean

true when the layout has been dirtied by requestRemeasure. false after the measurement has been complete (place has been called).

onAttach

var onAttach: (Owner) -> Unit

Callback to be executed whenever the LayoutNode is attached to a new Owner.

onDetach

var onDetach: (Owner) -> Unit

Callback to be executed whenever the LayoutNode is detached from an Owner.

parentData

val parentData: Any?

Data provided by the ParentData

parentLayoutNode

val parentLayoutNode: LayoutNode?

This is the LayoutNode ancestor that contains this LayoutNode. This will be null for the root LayoutNode.

positionedDuringMeasurePass

var positionedDuringMeasurePass: Boolean

true when the current node is positioned during the measure pass, since it needs to compute alignment lines.

ref

var ref: Ref<LayoutNode>?

Implementation oddity around composition; used to capture a reference to this LayoutNode when composed. This is a reverse property that mutates its right-hand side.

width

val width: IntPx

The measured width of this layout and all of its modifiers. Shortcut for size.width.