Creating complex layouts with Include, Merge, and ViewStubs

In this chapter we've built a single layout resource with three different tabs in it. As a result of this, the main.xml file has become quite large and hence, more difficult to manage. Android provides several ways in which you can break up large layout files (such as this one) into smaller chunks.

Using Include tags

The include tag is the simplest one to work with. It's a straight import of one layout XML file into another. For our previous example, we could separate each tab out into its own layout resource file, and then include each one in the main.xml. The include tag has only one mandatory attribute: layout. This attribute points to the layout resource to be included. This tag is ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.