When we created our main activity, the associated layout was also created. This is a way of creating a layout when creating an activity.
To add an independent layout without creating a new activity, right-click on the
layouts folder (
res/layout/) and navigate to New | Layout resource file. You can also navigate to this menu option like this: File | New | Layout resource file. Type the file name and the root element.
Once the layout is created, the associated activity can be changed from the editor to another one. If the layout has no activity, any existing activity can be linked to it from the editor. To accomplish this, search for the Associate with Activity option in the toolbar of the layout editor, click on it, and select ...