Develop
Develop
Select your platform

Modify the UI and layout

Updated: Oct 2, 2024
In this tutorial, you learn how to customize the content of a Spatial SDK panel and reposition it with the Spatial Editor. Existing Android UIs work out of the box with Spatial SDK Panels, which can render layout XML or even full Android Activities.

Before you begin

Step 1: Edit the Android UI layout file

In your scene, there’s a panel that says “Welcome” on it. The panel is generated by standard Android UI code. The layout for this UI is in main/res/layout/ui_example.xml. Edit the text in ui_example.xml to display “Hello, Spatial!” instead of “Welcome”.
  1. In Android Studio, open ui_example.xml.
    The folder structure for your layout files
  2. Change the XML in either “Code” view (shown below in the image) or “Design” view (if you want to edit the layout visually) to “Welcome”.
    Edit the text in ui_example.xml file.
  3. Rebuild the app to see the changes in your headset.

Step 2: Lay out your 3D scene with Spatial Editor

Earlier in this tutorial series, you downloaded Spatial Editor, the 3D scene editor for Spatial SDK. Let’s use it to modify the layout of your scene.
  1. On your computer, open the Spatial Editor app.
  2. Select Open Project, and then navigate to the Main.metaspatial file stored inside of /StarterSample/app/scenes.
    Note: Most of the sample projects come with a Main.metaspatial file stored inside of /app/scenes.
    Using Spatial Editor to open up the Main.metaspatial file"
  3. Open the Main.metaspatial file in Spatial Editor to see your scene.
    The scene in Spatial Editor"
  4. To move the panel up, in the 3D viewport, select the transform gizmo’s green arrow and drag it upwards.
  5. In the toolbar, select File > Save to save your composition.
  6. In Android Studio, rerun your app and put on your headset to see your changes.

Next steps

Did you find this page helpful?
Thumbs up icon
Thumbs down icon