From the course: Android Development Essential Training: The User Interface with Kotlin

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Distribute views with constraint chains

Distribute views with constraint chains - Android Tutorial

From the course: Android Development Essential Training: The User Interface with Kotlin

Start my 1-month free trial

Distribute views with constraint chains

- [Instructor] The ConstraintLayout ViewGroup has a feature named Chains that lets you distribute objects either horizontally or vertically on the screen. To demonstrate this I'm starting with an empty project and I'm going to drag in three button components and place them anywhere on the screen. Now for the first button, I'll line it to the top and to the left, and for the third button I'm going to align that to the right. Then I'm going to click on the first button, hold down the Shift key and click on the other two buttons, so they're all selected, and I'm going to align them to the top. I'll right-click and choose Align, Top Edges. And that chains the buttons together. The second button's top edge is aligned to the first button's top, the third one to the second one. Now I want to distribute the buttons evenly across the screen. Once again I'll make sure all three are selected. I'll right-click and choose Chains, and then Create Horizontal Chain. And now the buttons have an equal…

Contents