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

BoxScope

@LayoutScopeMarker
public interface BoxScope

Known direct subclasses
BoxWithConstraintsScope

Receiver scope being used by the children parameter of BoxWithConstraints


A BoxScope provides a scope for the children of Box and BoxWithConstraints.

Summary

Public methods

abstract @NonNull Modifier
align(@NonNull Modifier receiver, @NonNull Alignment alignment)

Pull the content element to a specific Alignment within the Box.

abstract @NonNull Modifier

Size the element to match the size of the Box after all other content elements have been measured.

Public methods

align

abstract @NonNull Modifier align(@NonNull Modifier receiver, @NonNull Alignment alignment)

Pull the content element to a specific Alignment within the Box. This alignment will have priority over the Box's alignment parameter.

matchParentSize

abstract @NonNull Modifier matchParentSize(@NonNull Modifier receiver)

Size the element to match the size of the Box after all other content elements have been measured.

The element using this modifier does not take part in defining the size of the Box. Instead, it matches the size of the Box after all other children (not using matchParentSize() modifier) have been measured to obtain the Box's size. In contrast, a general-purpose Modifier.fillMaxSize modifier, which makes an element occupy all available space, will take part in defining the size of the Box. Consequently, using it for an element inside a Box will make the Box itself always fill the available space.