For the More Curious: include and merge

Earlier in the chapter you used the include tag to include a row of RemoteButtons multiple times (into the same layout). It works in the obvious way:

 ​ ​ ​ ​<​i​n​c​l​u​d​e​ ​l​a​y​o​u​t​=​"​@​l​a​y​o​u​t​/​s​o​m​e​_​p​a​r​t​i​a​l​_​l​a​y​o​u​t​"​/​>​

The above include will include the contents of the layout file whose resource ID is @layout/some_partial_layout.

You can use include to reduce duplication in a single layout, as you did earlier in this chapter, or you can use it to reduce duplication between layouts. If you have some chunk of a layout that occurs in two or more layouts, you can just create that chunk as a layout and include it wherever it is needed. Then when you need to update it, you ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.