@@ -29,6 +29,9 @@ import androidx.xr.scenecore.MovableComponent
2929import androidx.xr.scenecore.PlaneSemantic
3030import androidx.xr.scenecore.PlaneType
3131import androidx.xr.scenecore.ResizableComponent
32+ import androidx.xr.scenecore.ResizeListener
33+ import androidx.xr.scenecore.SurfaceEntity
34+ import java.util.concurrent.Executor
3235import java.util.concurrent.Executors
3336
3437private fun setPoseExample (entity : Entity ) {
@@ -73,11 +76,26 @@ private fun moveableComponentExample(session: Session, entity: Entity) {
7376 // [END androidxr_scenecore_moveableComponentExample]
7477}
7578
76- private fun resizableComponentExample (session : Session , entity : Entity ) {
79+ private fun resizableComponentExample (session : Session , entity : Entity , executor : Executor ) {
7780 // [START androidxr_scenecore_resizableComponentExample]
7881 val resizableComponent = ResizableComponent .create(session)
7982 resizableComponent.minimumSize = Dimensions (177f , 100f , 1f )
8083 resizableComponent.fixedAspectRatio = 16f / 9f // Specify a 16:9 aspect ratio
84+
85+ resizableComponent.addResizeListener(
86+ executor,
87+ object : ResizeListener {
88+ override fun onResizeEnd (entity : Entity , finalSize : Dimensions ) {
89+
90+ // update the size in the component
91+ resizableComponent.size = finalSize
92+
93+ // update the Entity to reflect the new size
94+ (entity as SurfaceEntity ).canvasShape = SurfaceEntity .CanvasShape .Quad (finalSize.width, finalSize.height)
95+ }
96+ },
97+ )
98+
8199 entity.addComponent(resizableComponent)
82100 // [END androidxr_scenecore_resizableComponentExample]
83101}
0 commit comments