The Layout Editor has a new refactoring which allows you to select one or more views in a layout, and extract it into a separate layout. A new layout file is created with the selected views, and an <include> tag pointing to the new layout is inserted where the views used to appear.
This makes it easy to share visual elements between different layouts, which is particularly useful if you have various configuration versions (such as one layout for portrait mode, and one for landscape mode).
Here's how it works. Let's say you have a layout like this:
We'd like to extract the bottom message area into a separate layout. Right click on the LinearLayout containing the 3 label/field/button views and choose "Extract as Include":
You will then be prompted for a name for the new layout. If you've selected a single view to extract, and it has an id, then this id is suggested as a layout name:
When you hit OK, the views are pulled out of the old layout, a new layout file created with the formatting adjusted, the namespace declarations carried over, and the original views replaced by an <include> tag referencing the new layout. The new extracted layout is opened:
Recent Changes >