The Android Developer Challenge is back! Submit your idea before December 2.

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. All layout state such as modifiedSize and modifiedPosition also reflect the modified state of the node.

Summary

Nested classes

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.

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
place(x: IntPx, y: IntPx)

Unit

Unit

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

Inherited functions

Extension functions

From androidx.ui.core
PxPosition

Converts a child LayoutNode position into a local position within this LayoutNode.

PxPosition
LayoutNode.globalToLocal(global: PxPosition, withOwnerOffset: Boolean = true)

Converts a PxPosition relative to a global context into a PxPosition that is relative to this LayoutNode.

IntPxPosition
LayoutNode.globalToLocal(global: IntPxPosition, withOwnerOffset: Boolean = true)

Converts a IntPxPosition relative to a global context into a IntPxPosition that is relative to this LayoutNode.

PxPosition
LayoutNode.localToGlobal(local: PxPosition, withOwnerOffset: Boolean = true)

Converts an PxPosition that is relative to this LayoutNode into one that is relative to a more global context.

IntPxPosition
LayoutNode.localToGlobal(local: IntPxPosition, withOwnerOffset: Boolean = true)

Converts an IntPxPosition that is relative to this LayoutNode into one that is relative to a more global context.

PxPosition

Calculates the position of this LayoutNode relative to the provided ancestor.

IntPxPosition

Calculates the position of this LayoutNode relative to the root of the ui tree.

Inherited extension functions

From androidx.ui.core
Unit

Inserts a child ComponentNode at a last index.

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.

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.

IntPxPosition

The position of the inner layout node content

IntPxSize

The size of the inner layout node content

IntPx

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

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.

IntPxPosition

The position of this layout and all of its modifier within its parent.

IntPxSize

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

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.

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.

IntPx

The horizontal position of this layout and all of its modifiers within its parent.

IntPx

The vertical position of this layout and all of its modifiers within its parent.

Inherited properties

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. All layout state such as modifiedSize and modifiedPosition also reflect the modified state of the node.

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.

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.

place

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

placeChildren

fun placeChildren(): Unit

requestRemeasure

fun requestRemeasure(): Unit

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

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.

contentPosition

val contentPosition: IntPxPosition

The position of the inner layout node content

contentSize

val contentSize: IntPxSize

The size of the inner layout node content

height

val height: IntPx

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

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.

modifiedPosition

val modifiedPosition: IntPxPosition

The position of this layout and all of its modifier within its parent.

modifiedSize

val modifiedSize: IntPxSize

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

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

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.

x

val x: IntPx

The horizontal position of this layout and all of its modifiers within its parent.

y

val y: IntPx

The vertical position of this layout and all of its modifiers within its parent.