How to add Chains feature of constraint layout with design in android studio

saran chomphuphan picture saran chomphuphan · Nov 10, 2016 · Viewed 10.8k times · Source

I have two images in constraint layout. I want to use chains feature with design page in android studio but I can't find icon or menu that represent Chains feature.

Answer

Darish picture Darish · Mar 31, 2017

Update (2019 august 23)

The small buttons shown on the screenshots are now available on the right click menu, Google updated the UI for more easy layout operations.

How to add Chains feature of ConstraintLayout with Android Studio's 'Layout Editor'?

The chain style can be controlled by "chain" button right below the view:

enter image description here

Click on it few times to toggle between all 3 modes:

spread (the default one)

spread_inside

packed

Let's see some examples

centering views which are connected together using chain

  1. drag and drop three buttons into the Android Studio's 'Layout Editor'

  1. Select those buttons together by dragging mouse

  1. Pack them vertically using the 'pack' button in 'Layout Editor'

  1. Align them center horizontally using 'Align-Center horizontally' button

  1. Align them center vertically using the 'Align-Center vertically' button


Here we used the pack option. similar to this, you can try spread and spread inside options of chain to see the difference. cheers :)