Layout Editor in Android Studio is used for building layouts. It enables you to build layouts by dragging UI elements into a visual design editor instead of writing layout XML. The design editor can preview layout on different Android devices and versions. You can position the elements in the layout, add constraints, and set attributes.

Layout Editor appears when you open an XML layout file.

Parts of Layout Editor

Below figure shows layout editor in Android Studio.

Layout Editor in Android Studio
Layout Editor in Android Studio

Various component as marked in the above image are

  1. Palette: It provides a list of components and layouts that you can drag into your layout in the editor.
  2. Component Tree: It shows the hierarchy of components in layout.
  3. Toolbar: It provides buttons to configure layout appearance in the editor and change layout attributes. You can preview the layout on different size of the display to check if constraints work as expected. It also has controls for find alignments and connection tools.
  4. Design editor: Edit your layout in Design view, Blueprint view, or both.
  5. Attributes: It shoes the controls for the selected view’s attributes. Attributes are properties for components in layout. It will describe visual aspects of components.
  6. View mode: Configure view of layout in either Code, Design or Split. Split mode shows both the Code and Design windows at the same time.

Create New layout

New layout using Android Studio’s main menu

  • Click the module in project windows.
  • Go to File > New > XML > Layout XML File, in the main menu.
  • In the dialog that appears, set the file name and follow the instruction.
  • Click Finish to create the layout.
Project View in Android Studio
Project View in Android Studio

To create new layout using Project view

  • Choose the Project view from within the Project window.
  • Right-click the layout directory where you’d like to add the layout.
  • In the context menu that appears, click New > Layout Resource File.

To create new layout using Resource Manager

  • In the Resource Manager, select the Layout tab.
  • Click the + button, and then click Layout Resource File.
New layout using Resource Manager
New layout using Resource Manager

Reference

Build a UI with Layout Editor