O'Reilly logo

Android User Interface Development by Jason Morris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required