Intro to Android

View Groups

A way to organize and simplify your XML layouts is to use view groups. You can use them to hold children views and make reusable components. You can also extend them to add your own behavior.

Here are some of the most commonly used options.


This is the simplest of the view groups. It's designed to hold one child view. This layout is often used as a holder for dynamic fragments.

Frame Layout


As the name implies, with this name you lay view items out in a line, either vertically or horizontally.

Linear Layout


With this view group, you can lay out elements in a relative fashion. For example, place the star to the right of the circle and the heart below the circle.

Relative Layout


With this view group, you can lay out similar elements in a grid fashion. This available in later OS versions and has been back ported for older OS versions.

Grid Layout

View Stubs

When your views start to get complicated, you can break it up using view stubs. This can be used to lazily inflate views at runtime.

More information here: