Compose Modifier

wrapContentSize

Allow the content to measure at its desired size without regard for the incoming measurement minimum widthConstraints.minWidth or minimum heightConstraints.minHeight constraints, and, if unbounded is true, also without regard for the incoming maximum constraints.

wrapContentSize

Source set: Common

Added in 1.11.0-rc01

fun Modifier.wrapContentSize(align: Alignment = Alignment.Center, unbounded: Boolean = false) =
    this.then(
        if (align == Alignment.Center && !unbounded) {
            WrapContentSizeCenter
        } else if (align == Alignment.TopStart && !unbounded) {
            WrapContentSizeTopStart
        } else {
            WrapContentElement.size(align, unbounded)
        }
    )

Allow the content to measure at its desired size without regard for the incoming measurement minimum width or minimum height constraints, and, if unbounded is true, also without regard for the incoming maximum constraints. If the content's measured size is smaller than the minimum size constraint, align it within that minimum sized space. If the content's measured size is larger than the maximum size constraint (only possible when unbounded is true), align within the maximum space.

Last updated: