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, if you have an ImageView, you can attach a constraint from its right edge to the right edge of its parent (the ConstraintLayout itself), as shown in Figure 10.2. The constraint will hold the ImageView to the right.

Figure 10.2  ImageView with a constraint on the right edge

ImageView with a constraint on the right edge

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

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.