If you have a ConstraintLayout with some size, and a child View with some smaller size, you can achieve centering by constraining the child’s two edges to the same two edges of the parent and set width to 0dp. That is, you can write:
app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"
Or
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent"
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"> <TextView android:id="@+id/stat_1" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginEnd="8dp" android:gravity="center" android:maxLines="1" android:text="10" android:textColor="#777" android:textSize="22sp" app:layout_constraintTop_toTopOf="@+id/stat_2" app:layout_constraintEnd_toStartOf="@+id/divider_1" /> <TextView android:id="@+id/stat_detail_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Streak" android:textColor="#777" android:textSize="12sp" app:layout_constraintTop_toBottomOf="@+id/stat_1" app:layout_constraintStart_toStartOf="@+id/stat_1" app:layout_constraintEnd_toEndOf="@+id/stat_1" /> <View android:id="@+id/divider_1" android:layout_width="1dp" android:layout_height="0dp" android:layout_marginEnd="16dp" android:background="#ccc" app:layout_constraintTop_toTopOf="@+id/stat_2" app:layout_constraintEnd_toStartOf="@+id/stat_2" app:layout_constraintBottom_toBottomOf="@+id/stat_detail_2" /> <TextView android:id="@+id/stat_2" android:layout_width="80dp" android:layout_height="wrap_content" android:gravity="center" android:maxLines="1" android:text="243" android:textColor="#777" android:textSize="22sp" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toBottomOf="parent" /> <TextView android:id="@+id/stat_detail_2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="1" android:text="Calories Burned" android:textColor="#777" android:textSize="12sp" app:layout_constraintTop_toBottomOf="@+id/stat_2" app:layout_constraintStart_toStartOf="@+id/stat_2" app:layout_constraintEnd_toEndOf="@+id/stat_2" /> <View android:id="@+id/divider_2" android:layout_width="1dp" android:layout_height="0dp" android:layout_marginStart="16dp" android:background="#ccc" app:layout_constraintBottom_toBottomOf="@+id/stat_detail_2" app:layout_constraintStart_toEndOf="@+id/stat_2" app:layout_constraintTop_toTopOf="@+id/stat_2" /> <TextView android:id="@+id/stat_3" android:layout_width="80dp" android:layout_height="wrap_content" android:layout_marginStart="8dp" android:gravity="center" android:maxLines="1" android:text="3200" android:textColor="#777" android:textSize="22sp" app:layout_constraintTop_toTopOf="@+id/stat_2" app:layout_constraintStart_toEndOf="@+id/divider_2" /> <TextView android:id="@+id/stat_detail_3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:maxLines="1" android:text="Steps" android:textColor="#777" android:textSize="12sp" app:layout_constraintTop_toBottomOf="@+id/stat_3" app:layout_constraintStart_toStartOf="@+id/stat_3" app:layout_constraintEnd_toEndOf="@+id/stat_3" /> </android.support.constraint.ConstraintLayout>
References
https://stackoverflow.com/questions/45220013/constraint-layout-vertical-align-center