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

LayoutNode

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

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

Summary

Nested classes
enum

Describes the current state the LayoutNode is in.

abstract

abstract

Public constructors

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

Public methods
Unit
attach(owner: Owner)

Set the Owner of this LayoutNode.

Unit

Remove the LayoutNode from the Owner.

Unit
draw(canvas: Canvas)

Int?

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

List<ModifierInfo>

This returns a new List of Modifiers and the coordinates and any extra information that may be useful.

Unit
hitTest(pointerPositionRelativeToScreen: Offset, hitPointerInputFilters: MutableList<PointerInputFilter>)

Carries out a hit test on the PointerInputModifiers associated with this LayoutNode and all PointerInputModifiers on all descendant LayoutNodes.

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
insertAt(index: Int, instance: LayoutNode)

Inserts a child LayoutNode at a particular index.

Int
maxIntrinsicHeight(width: Int, layoutDirection: LayoutDirection)

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

Int
maxIntrinsicWidth(height: Int, layoutDirection: LayoutDirection)

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

Placeable
measure(constraints: Constraints, layoutDirection: LayoutDirection)

Measures the layout with constraints and a layoutDirection, returning a Placeable layout that has its new size.

Int
minIntrinsicHeight(width: Int, layoutDirection: LayoutDirection)

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

Int
minIntrinsicWidth(height: Int, layoutDirection: LayoutDirection)

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

Unit
move(from: Int, to: Int, count: Int)

Moves count elements starting at index from to index to.

Unit

Used to request a new draw pass from the owner.

Unit
place(x: Int, y: Int)

Unit

Removes all children.

Unit
removeAt(index: Int, count: Int)

Removes one or more children, starting at index.

Unit

Used to request a new layout pass from the owner.

Unit

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

String

Extension functions
From androidx.ui.core
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.

Properties
Boolean

List<LayoutNode>

The children of this LayoutNode, controlled by insertAt, move, and removeAt.

LayoutCoordinates

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

Int

The tree depth of the LayoutNode.

Int

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

Boolean

Whether or not this has been placed in the hierarchy.

LayoutNode.LayoutState

The layout state the node is currently in.

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.

(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.

Owner?

The view system Owner.

LayoutNode?

The parent node in the LayoutNode hierarchy.

Any?

Data provided by the ParentData

Int

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

Inherited extension properties
From androidx.ui.core
Any?

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

Any?

Public constructors

<init>

LayoutNode()

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

Public methods

attach

fun attach(owner: Owner): Unit

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

detach

fun detach(): Unit

Remove the LayoutNode 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): Unit

getAlignmentLine

fun getAlignmentLine(line: AlignmentLine): Int?

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

getModifierInfo

fun getModifierInfo(): List<ModifierInfo>

This returns a new List of Modifiers and the coordinates and any extra information that may be useful. This is used for tooling to retrieve layout modifier and layer information.

hitTest

fun hitTest(
    pointerPositionRelativeToScreen: Offset,
    hitPointerInputFilters: MutableList<PointerInputFilter>
): Unit

Carries out a hit test on the PointerInputModifiers associated with this LayoutNode and all PointerInputModifiers on all descendant LayoutNodes.

If pointerPositionRelativeToScreen is within the bounds of any tested PointerInputModifiers, the PointerInputModifier is added to hitPointerInputFilters and true is returned.

Parameters
pointerPositionRelativeToScreen: Offset The tested pointer position, which is relative to the device screen.
hitPointerInputFilters: MutableList<PointerInputFilter> The collection that the hit PointerInputFilters will be added to if hit.

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.

insertAt

fun insertAt(
    index: Int,
    instance: LayoutNode
): Unit

Inserts a child LayoutNode at a particular index. If this LayoutNode owner is not null then instance will become attached also. instance must have a null parent.

maxIntrinsicHeight

fun maxIntrinsicHeight(
    width: Int,
    layoutDirection: LayoutDirection
): Int

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

maxIntrinsicWidth

fun maxIntrinsicWidth(
    height: Int,
    layoutDirection: LayoutDirection
): Int

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

measure

fun measure(
    constraints: Constraints,
    layoutDirection: LayoutDirection
): Placeable

Measures the layout with constraints and a layoutDirection, returning a Placeable layout that has its new size. A Measurable can only be measured once inside a layout pass.

minIntrinsicHeight

fun minIntrinsicHeight(
    width: Int,
    layoutDirection: LayoutDirection
): Int

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

minIntrinsicWidth

fun minIntrinsicWidth(
    height: Int,
    layoutDirection: LayoutDirection
): Int

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

move

fun move(
    from: Int,
    to: Int,
    count: Int
): Unit

Moves count elements starting at index from to index to. The to index is related to the position before the change, so, for example, to move an element at position 1 to after the element at position 2, from should be 1 and to should be 3. If the elements were LayoutNodes A B C D E, calling move(1, 3, 1) would result in the LayoutNodes being reordered to A C B D E.

onInvalidate

fun onInvalidate(): Unit

Used to request a new draw pass from the owner.

place

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

removeAll

fun removeAll(): Unit

Removes all children.

removeAt

fun removeAt(
    index: Int,
    count: Int
): Unit

Removes one or more children, starting at index.

requestRelayout

fun requestRelayout(): Unit

Used to request a new layout pass from the owner.

requestRemeasure

fun requestRemeasure(): Unit

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

toString

fun toString(): String

Properties

canMultiMeasure

var canMultiMeasure: Boolean

Deprecated.

children

val children: List<LayoutNode>

The children of this LayoutNode, controlled by insertAt, move, and removeAt.

coordinates

val coordinates: LayoutCoordinates

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

depth

var depth: Int

The tree depth of the LayoutNode. This is valid only when owner is not null.

height

val height: Int

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

isPlaced

var isPlaced: Boolean

Whether or not this has been placed in the hierarchy.

layoutState

var layoutState: LayoutNode.LayoutState

The layout state the node is currently in.

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.

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.

owner

var owner: Owner?

The view system Owner. This null until attach is called

parent

var parent: LayoutNode?

The parent node in the LayoutNode hierarchy. This is null when the LayoutNode is attached (has an owner) and is the root of the tree or has not had add called for it.

parentData

val parentData: Any?

Data provided by the ParentData

width

val width: Int

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