Sign in Go Pro

Constraint Layout

Dimension Ratios

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next

Previous

About

In this lesson, we're going to show how you can use dimension ratios in the `ConstraintLayout` to define one dimension of a view as a ratio of the other one. These features allow us to apply an aspect ratio to the width and height of our views. This comes in handy for neatly sizing content that has an intrinsic aspect ratio like images or for easily creating square views. We will review the valid formats for specifying ratios, discuss the behavior of dimension ratios with one or both dimensions under `match_constraint`, and look at examples of using the `W` and `H` prefixes on dimension ratios to control which dimension is constrained.

Lessons in Constraint Layout