{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

SemanticsNode

public final class SemanticsNode


A list of key/value pairs associated with a layout node or its subtree.

Each SemanticsNode takes its id and initial key/value list from the outermost modifier on one layout node. It also contains the "collapsed" configuration of any other semantics modifiers on the same layout node, and if "mergeDescendants" is specified and enabled, also the "merged" configuration of its subtree.

Summary

Public methods

final int

Returns the position of an alignment line, or AlignmentLine.Unspecified if the line is not provided.

final @NonNull Rect

The bounding box for this node relative to the root of this Compose hierarchy, with clipping applied.

final @NonNull Rect

The bounding box for this node relative to the screen, with clipping applied.

final @NonNull List<@NonNull SemanticsNode>

Contains the children in inverse hit test order (i.e. paint order).

final @NonNull SemanticsConfiguration

The list of semantics properties of this node.

final int

For newer AccessibilityNodeInfo-based integration test frameworks, it can be matched in the extras with key "androidx.compose.ui.semantics.id"

final @NonNull LayoutInfo

The LayoutInfo that this is associated with.

final boolean
final SemanticsNode

The parent of this node in the tree.

final @NonNull Offset

The position of this node relative to the root of this Compose hierarchy, with no clipping applied

final @NonNull Offset

The position of this node relative to the screen, with no clipping applied

final RootForTest

The root this node is attached to.

final @NonNull IntSize

The size of the bounding box for this node, with no clipping applied

final @NonNull Rect

The rectangle of the touchable area.

final boolean

Whether this SemanticNode is the root of a tree or not

Public methods

getAlignmentLinePosition

public final int getAlignmentLinePosition(@NonNull AlignmentLine alignmentLine)

Returns the position of an alignment line, or AlignmentLine.Unspecified if the line is not provided.

getBoundsInRoot

public final @NonNull Rect getBoundsInRoot()

The bounding box for this node relative to the root of this Compose hierarchy, with clipping applied. To get the bounds with no clipping applied, use Rect(positionInRoot, size.toSize())

getBoundsInWindow

public final @NonNull Rect getBoundsInWindow()

The bounding box for this node relative to the screen, with clipping applied. To get the bounds with no clipping applied, use PxBounds(positionInWindow, size.toSize())

getChildren

public final @NonNull List<@NonNull SemanticsNodegetChildren()

Contains the children in inverse hit test order (i.e. paint order).

Note that if mergingEnabled and mergeDescendants are both true, then there are no children (except those that are themselves mergeDescendants).

getConfig

public final @NonNull SemanticsConfiguration getConfig()

The list of semantics properties of this node.

This includes all properties attached as modifiers to the current layout node. In addition, if mergeDescendants and mergingEnabled are both true, then it also includes the semantics properties of descendant nodes.

getId

public final int getId()

For newer AccessibilityNodeInfo-based integration test frameworks, it can be matched in the extras with key "androidx.compose.ui.semantics.id"

getLayoutInfo

public final @NonNull LayoutInfo getLayoutInfo()

The LayoutInfo that this is associated with.

getMergingEnabled

public final boolean getMergingEnabled()

getParent

public final SemanticsNode getParent()

The parent of this node in the tree.

getPositionInRoot

public final @NonNull Offset getPositionInRoot()

The position of this node relative to the root of this Compose hierarchy, with no clipping applied

getPositionInWindow

public final @NonNull Offset getPositionInWindow()

The position of this node relative to the screen, with no clipping applied

getRoot

public final RootForTest getRoot()

The root this node is attached to.

getSize

public final @NonNull IntSize getSize()

The size of the bounding box for this node, with no clipping applied

getTouchBoundsInRoot

public final @NonNull Rect getTouchBoundsInRoot()

The rectangle of the touchable area.

If this is a clickable region, this is the rectangle that accepts touch input. This can be larger than size when the layout is less than ViewConfiguration.minimumTouchTargetSize

isRoot

public final boolean isRoot()

Whether this SemanticNode is the root of a tree or not