Skip to Content

Creating View Arrangements

Learn about common Android ViewGroups like ConstraintLayout and LinearLayout, which enable us to bring complex designs to life

Isolated Views hardly warrant a user’s attention—we’ve personally never downloaded a One Line of Text In The Middle of the Screen app, but maybe that’s just us. Let’s explore how ViewGroups and the attributes they define help us arrange multiple Views into valuable designs.

We will meet ConstraintLayout and LinearLayout, two of Android’s most well-known ViewGroups; the former arranges Views relative to other Views, and the latter arranges them in straight lines. When we use ViewGroups in tandem with Android’s cornucopia of interface components, we may form exceptionally complex designs without ever building a custom View class.


  • ConstraintLayout arranges its children relative to itself and other children (leftOf, rightOf, below, etc.).
  • LinearLayout arranges its children in a straight line, either horizontally or vertically.
  • Children of ConstraintLayout must provide one horizontal and one vertical constraint to define their position within the ConstraintLayout.
  • ConstraintLayout is primarily ‘bottom-up,’ as it requires its children to supply position-related attributes, whereas LinearLayout is ‘top-down’ and dictates the final position to each child.
  • Margins introduce space between Views, and Views often benefit from the “breathing room” margins provide.

Ready to Learn More?

Find the course that's right for you! Explore our catalog or get a recommendation.