absoluteOffset

Compose Modifier

Common
fun Modifier.absoluteOffset(x: Dp = 0.dp, y: Dp = 0.dp) =
    this then
        OffsetElement(
            x = x,
            y = y,
            rtlAware = false,
            inspectorInfo = {
                name = "absoluteOffset"
                properties["x"] = x
                properties["y"] = y
            },
        )

Offset the content by (x dp, y dp). The offsets can be positive as well as non-positive. Applying an offset only changes the position of the content, without interfering with its size measurement.

This modifier will not consider layout direction when calculating the position of the content: a positive x offset will always move the content to the right. For a modifier that considers the layout direction when applying the offset, see offset.

Common
fun Modifier.absoluteOffset(offset: Density.() -> IntOffset) =
    this then
        OffsetPxElement(
            offset = offset,
            rtlAware = false,
            inspectorInfo = {
                name = "absoluteOffset"
                properties["offset"] = offset
            },
        )

Offset the content by offset px. The offsets can be positive as well as non-positive. Applying an offset only changes the position of the content, without interfering with its size measurement.

This modifier is designed to be used for offsets that change, possibly due to user interactions. It avoids recomposition when the offset is changing, and also adds a graphics layer that prevents unnecessary redrawing of the context when the offset is changing.

This modifier will not consider layout direction when calculating the position of the content: a positive horizontal offset will always move the content to the right. For a modifier that considers layout direction when applying the offset, see offset.