Introducing ConstraintLayout

With ConstraintLayout, instead of using nested layouts you add a series of constraints to your layout. A constraint is like a rubber band. It pulls two things toward each other. So, for example, you can attach a constraint from the right edge of an ImageView to the right edge of its parent (the ConstraintLayout itself), as shown in Figure 9.3. The constraint will hold the ImageView to the right.

Figure 9.3  ImageView with a constraint on the right edge

Figure shows a rectangle with a process symbol reading, ImageView on the right. Flowline flows on the right side of the process symbol.

You can create a constraint from all four edges of your ImageView (left, top, right, and bottom). If you have opposing constraints, they will ...

Get Android Programming: The Big Nerd Ranch Guide, Third Edition 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.