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
system(onResize: ((SpatialResizeEvent) -> Unit)?)

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

Public companion properties

ResizePolicy

The default system-handled resize policy.

Public companion functions

custom

Added in 1.0.0-alpha17
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 system.

Parameters
onResize: (SpatialResizeEvent) -> Unit

Callback invoked during the interaction containing the calculated target size.

system

Added in 1.0.0-alpha17
fun system(onResize: ((SpatialResizeEvent) -> Unit)? = null): ResizePolicy

Resize 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)? = null

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.

Public companion properties

Default

Added in 1.0.0-alpha17
val DefaultResizePolicy

The default system-handled resize policy.