Chains in ConstraintLayout

Alexander Portillo
2 min readJul 13, 2021

--

In this article, I will explain how chains work and you will see why they are so useful. So you may be wondering when to use chains in your layouts. It is very helpful when you are looking to evenly space out views in your layout. It is similar to weights in a LinearLayout but chains can do much more.

How to Create a Chain

To create a chain you need to select all the views that you would like chained and right-click. From there, look for “Chains” and you can either select “Create Horizontal Chain” or “Create Vertical Chain”.

Types of Chains

  1. The first style of chain is “Spread”. This is where the views are evenly spaced out between each other.

2. The second style of chain is called “Spread Inside”. This is where the outermost views are set to the edges and the rest of the views are evenly spaced apart.

3. The last style of chain is called “Packed”. This will group all the views as closely as possible.

Hope this helped you guys learn something new and I would recommend messing around with chains in your layout. They are very useful to use!

--

--

Alexander Portillo
Alexander Portillo

Written by Alexander Portillo

21 Years Old | Pursuing Android Development

No responses yet