Chains
suggest changeSince ConstraintLayout alpha 9, chains are available. A chain is a set of views inside a ConstraintLayout that are connected in both directions: A is constrained to B, and B is constrained to A.
Example:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- this view is linked to the bottomTextView -->
<TextView
android:id="@+id/topTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
app:layout_constraintBottom_toTopOf="@+id/bottomTextView"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed"/>
<!-- this view is linked to the topTextView at the same time -->
<TextView
android:id="@+id/bottomTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bottom\nMkay"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topTextView"/>
</android.support.constraint.ConstraintLayout>
In this example, the two views are stacked and centered vertically. Change their vertical position by adjusting the chain bias. Add the following attribute to the first element of the chain:
app:layout_constraintVertical_bias="0.2"
In a vertical chain, the first element is the topmost view. In a horizontal chain, it is the leftmost view. The first element defines how the chain is packed and aligned.
The chain style belongs on that head view as app:layout_constraintVertical_chainStyle (or layout_constraintHorizontal_chainStyle). packed keeps the views together; spread and spread_inside distribute them. The ConstraintLayout reference documents chains.