# ResizableComponent

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/ResizableComponent.kt+class:androidx.xr.scenecore.ResizableComponent) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class ResizableComponent extends Component
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.xr.scenecore.Component](https://developer.android.com/reference/androidx/xr/scenecore/Component) ||
|   | ↳ | [androidx.xr.scenecore.ResizableComponent](https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent) |

*** ** * ** ***

This `https://developer.android.com/reference/androidx/xr/scenecore/Component` can be attached to a single instance of an `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. When attached, this Component will enable the user to resize the Entity by selecting and dragging along the boundaries of a user-resize affordance. While resizing an overlay will appear indicating the proposed updated size.

This component cannot be attached to an `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace` or to the `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`. Calling `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)` to an Entity with these types will return false.

Note: This Component is currently unsupported on GltfModelEntity.

## Summary

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#addResizeEventListener(java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizeEvent> resizeEventListener )` Adds the listener to the set of listeners that are invoked through the resize operation, such as start, ongoing and end. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#create(androidx.xr.runtime.Session,androidx.xr.runtime.math.FloatSize3d,androidx.xr.runtime.math.FloatSize3d,java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d minimumSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d maximumSize, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizeEvent> resizeEventListener )` Public factory function for creating a ResizableComponent. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#getAffordanceSize()()` The current size of the affordance for the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, in meters. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#getMaximumEntitySize()()` An upper bound for the User's resize actions, in meters. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#getMinimumEntitySize()()` A lower bound for the User's resize actions, in meters. |
| `final boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#isAlwaysShowOverlayEnabled()()` Whether a resize overlay will be shown even if the entity is not being resized. |
| `final boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#isAutoHideContentWhileResizingEnabled()()` Whether the content of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, and all child Entities, will be automatically hidden while it is being resized. |
| `final boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#isFixedAspectRatioEnabled()()` Whether the aspect ratio is maintained during resizing. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#removeResizeEventListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizeEvent> resizeEventListener )` Removes a listener from the set listening to resize events. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#setAffordanceSize(androidx.xr.runtime.math.FloatSize3d)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d value)` The current size of the affordance for the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, in meters. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#setAlwaysShowOverlayEnabled(kotlin.Boolean)(boolean value)` Whether a resize overlay will be shown even if the entity is not being resized. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#setAutoHideContentWhileResizingEnabled(kotlin.Boolean)(boolean value)` Whether the content of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, and all child Entities, will be automatically hidden while it is being resized. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#setFixedAspectRatioEnabled(kotlin.Boolean)(boolean value)` Whether the aspect ratio is maintained during resizing. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#setMaximumEntitySize(androidx.xr.runtime.math.FloatSize3d)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d value)` An upper bound for the User's resize actions, in meters. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#setMinimumEntitySize(androidx.xr.runtime.math.FloatSize3d)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d value)` A lower bound for the User's resize actions, in meters. |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#onAttach(androidx.xr.scenecore.Entity)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity entity)` Called by the framework when this component is being added to an `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. |
| `void` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent#onDetach(androidx.xr.scenecore.Entity)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity entity)` Called by the framework when this component is being removed from an `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. |

## Public methods

### addResizeEventListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addResizeEventListener(
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)
```

Adds the listener to the set of listeners that are invoked through the resize operation, such as start, ongoing and end.

The listener is invoked on the provided `https://developer.android.com/reference/java/util/concurrent/Executor.html` if provided.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | The Executor to run the listener on. By default, listener is invoked on the main thread. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizeEvent> resizeEventListener` | The listener to be invoked when a resize event occurs. |

### create

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public static final @NonNull ResizableComponent create(
    @NonNull Session session,
    @NonNull FloatSize3d minimumSize,
    @NonNull FloatSize3d maximumSize,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)
```

Public factory function for creating a ResizableComponent.

This `https://developer.android.com/reference/androidx/xr/scenecore/Component` can be attached to a single instance of an `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. When attached, this Component will enable the user to resize the Entity by dragging along the boundaries of a user-resize affordance.

This component cannot be attached to an `https://developer.android.com/reference/androidx/xr/scenecore/AnchorSpace` or to the `https://developer.android.com/reference/androidx/xr/scenecore/ActivitySpace`. Calling `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)` to an Entity with these types will return false.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/Session session` | The `https://developer.android.com/reference/androidx/xr/runtime/Session` to create the ResizableComponent in. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d minimumSize` | A lower bound for the User's resize actions, in meters. This value is used to set constraints on how small the user can resize the bounding box of the entity down to. The size of the content inside that bounding box is fully controlled by the application. The default value is 0 meters. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize3d maximumSize` | An upper bound for the User's resize actions, in meters. This value is used to set constraints on how large the user can resize the bounding box of the entity up to. The size of the content inside that bounding box is fully controlled by the application. The default value is 10 meters. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html executor` | The Executor to run the listener on. By default, listener is invoked on the main thread. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizeEvent> resizeEventListener` | A resize event listener for the event. The application should set the size of a PanelEntity using `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#size()`. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent` | `https://developer.android.com/reference/androidx/xr/scenecore/ResizableComponent` instance. |

### getAffordanceSize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull FloatSize3d getAffordanceSize()
```

The current size of the affordance for the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, in meters. This property is automatically updated after resize events to match the resize affordance to the newly suggested size of the content. The apps can still override it. The default value is set to 1 meter. If attached to a `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity`, this is updated to the size of the Entity when attached.

### getMaximumEntitySize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull FloatSize3d getMaximumEntitySize()
```

An upper bound for the User's resize actions, in meters. This value constrains large the user can resize the bounding box of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. The size of the content inside that bounding box is fully controlled by the application.

### getMinimumEntitySize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final @NonNull FloatSize3d getMinimumEntitySize()
```

A lower bound for the User's resize actions, in meters. This value constrains how small the user can resize the bounding box of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. The size of the content inside that bounding box is fully controlled by the application.

### isAlwaysShowOverlayEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final boolean isAlwaysShowOverlayEnabled()
```

Whether a resize overlay will be shown even if the entity is not being resized.

This is useful for resizing multiple panels at once.

### isAutoHideContentWhileResizingEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final boolean isAutoHideContentWhileResizingEnabled()
```

Whether the content of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, and all child Entities, will be automatically hidden while it is being resized.

### isFixedAspectRatioEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final boolean isFixedAspectRatioEnabled()
```

Whether the aspect ratio is maintained during resizing.

If true the affordance will maintain its current aspect ratio being resized and all suggested sizes will maintain the current aspect ratio. This defaults to false.

### removeResizeEventListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void removeResizeEventListener(
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)
```

Removes a listener from the set listening to resize events.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ResizeEvent> resizeEventListener` | The listener to be removed. |

### setAffordanceSize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setAffordanceSize(@NonNull FloatSize3d value)
```

The current size of the affordance for the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, in meters. This property is automatically updated after resize events to match the resize affordance to the newly suggested size of the content. The apps can still override it. The default value is set to 1 meter. If attached to a `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity`, this is updated to the size of the Entity when attached.

### setAlwaysShowOverlayEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setAlwaysShowOverlayEnabled(boolean value)
```

Whether a resize overlay will be shown even if the entity is not being resized.

This is useful for resizing multiple panels at once.

### setAutoHideContentWhileResizingEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setAutoHideContentWhileResizingEnabled(boolean value)
```

Whether the content of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`, and all child Entities, will be automatically hidden while it is being resized.

### setFixedAspectRatioEnabled

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setFixedAspectRatioEnabled(boolean value)
```

Whether the aspect ratio is maintained during resizing.

If true the affordance will maintain its current aspect ratio being resized and all suggested sizes will maintain the current aspect ratio. This defaults to false.

### setMaximumEntitySize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setMaximumEntitySize(@NonNull FloatSize3d value)
```

An upper bound for the User's resize actions, in meters. This value constrains large the user can resize the bounding box of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. The size of the content inside that bounding box is fully controlled by the application.

### setMinimumEntitySize

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void setMinimumEntitySize(@NonNull FloatSize3d value)
```

A lower bound for the User's resize actions, in meters. This value constrains how small the user can resize the bounding box of the `https://developer.android.com/reference/androidx/xr/scenecore/Entity`. The size of the content inside that bounding box is fully controlled by the application.

## Protected methods

### onAttach

```
protected boolean onAttach(@NonNull Entity entity)
```

Called by the framework when this component is being added to an `https://developer.android.com/reference/androidx/xr/scenecore/Entity`.

This method is triggered when `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)` is invoked. Implementations should override this method to perform setup logic or to validate if the component is compatible with the provided `https://developer.android.com/reference/androidx/xr/scenecore/Component#onAttach(androidx.xr.scenecore.Entity)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity entity` | The `https://developer.android.com/reference/androidx/xr/scenecore/Entity` to which this component is being attached. |

| Returns |
|---|---|
| `boolean` | `true` if the component was successfully attached; `false` if the `https://developer.android.com/reference/androidx/xr/scenecore/Component#onAttach(androidx.xr.scenecore.Entity)` does not support this component or if attachment failed. |

### onDetach

```
protected void onDetach(@NonNull Entity entity)
```

Called by the framework when this component is being removed from an `https://developer.android.com/reference/androidx/xr/scenecore/Entity`.

This method is triggered when `https://developer.android.com/reference/androidx/xr/scenecore/Entity#removeComponent(androidx.xr.scenecore.Component)` is invoked. Implementations should override this method to release resources or undo any changes made during `https://developer.android.com/reference/androidx/xr/scenecore/Component#onAttach(androidx.xr.scenecore.Entity)`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity entity` | The `https://developer.android.com/reference/androidx/xr/scenecore/Entity` from which this component is being detached. |