ResizePolicy

sealed interface ResizePolicy


Defines how resizing interactions are applied and handled for SubspaceModifier.resizable.

Summary

Public companion functions

ResizePolicy
custom(onResize: (SpatialResizeEvent) -> Unit)

Custom resizing policy where the developer is fully responsible for applying the new dimensions to the content (e.g., by updating a state that backs width/height).

ResizePolicy

Default resizing policy where the system automatically handles the resize gesture and applies the new dimensions to the content under the hood.

Public companion functions

custom

Added in 1.0.0-alpha16
fun custom(onResize: (SpatialResizeEvent) -> Unit): ResizePolicy

Custom resizing policy where the developer is fully responsible for applying the new dimensions to the content (e.g., by updating a state that backs width/height). This is necessary for situations where the overall layout should be readjusted after the resize event. Using this policy has higher latency than default.

Parameters
onResize: (SpatialResizeEvent) -> Unit

Callback invoked during the interaction containing the calculated target size.

default

Added in 1.0.0-alpha16
fun default(onResize: (SpatialResizeEvent) -> Unit = {}): ResizePolicy

Default resizing policy where the system automatically handles the resize gesture and applies the new dimensions to the content under the hood. This policy will not update the layout size of the object inside its parent. For instance, if used on an object inside a androidx.xr.compose.subspace.SpatialRow, the object size will change but the row size will not, potentially resulting in 3D object overlaps, unless the object is also paired with a movable modifier. Removing a modifier using this policy will reset the user resize state, causing the object to revert to its layout size.

Parameters
onResize: (SpatialResizeEvent) -> Unit = {}

Optional observer callback invoked during the interaction to monitor resize events. Since the system automatically applies the resize, this callback is strictly for monitoring changes and should not be used to update the content size.