title: Constraint Layout Vertical Align Center
body: <p>How to vertically align and center objects in constraint layout? It is possible to align vertically or horizontally but I have not found a way to center at the same time beside constraining the views between two gridlines. </p>
  
  <p>Vertical Align Center:
  <a href="https://i.stack.imgur.com/lBO3P.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lBO3P.png" alt="enter image description here"></a></p>
  
  <p>It seems like centering is a huge problem with constraint layout which forces me to go back to relative layout for "centerInParent", "centerVertical", and "centerHorizontal". </p>
  
  <p>I would like to create the layout boxed in red using constraint layout:
  <a href="https://i.stack.imgur.com/H6pvq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/H6pvq.png" alt="enter image description here"></a></p>
  
  <p>Unfortunately, the only way I found without using two gridlines is with nested Relative and LinearLayouts (which Constraint Layout was supposed to solve this exact scenario!).</p>
  
  <p>Layout using Relative and Linear Layout:</p>
  
  <pre><code>&lt;RelativeLayout
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginTop="12dp"
      app:layout_constraintTop_toBottomOf="@id/user_points"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"&gt;
  
      &lt;LinearLayout
          android:id="@+id/stat_1_layout"
          android:layout_width="60dp"
          android:layout_height="wrap_content"
          android:layout_marginLeft="12dp"
          android:layout_marginRight="12dp"
          android:layout_centerVertical="true"
          android:layout_toLeftOf="@+id/divider_1"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/stat_1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:gravity="center_horizontal"
              android:text="10"
              android:textSize="16dp"
              android:textColor="@color/textSecondaryDark"
              android:maxLines="1"/&gt;
  
          &lt;TextView
              android:id="@+id/stat_detail_1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:gravity="center"
              android:text="Streak"
              android:textSize="8sp"
              android:textColor="@color/textSecondary"
              android:maxLines="1"/&gt;
      &lt;/LinearLayout&gt;
  
      &lt;View
          android:id="@+id/divider_1"
          android:layout_width="1dp"
          android:layout_height="38dp"
          android:layout_toLeftOf="@+id/stat_2_layout"
          android:background="@drawable/linedivider"/&gt;
  
      &lt;LinearLayout
          android:id="@+id/stat_2_layout"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginLeft="18dp"
          android:layout_marginRight="18dp"
          android:layout_centerInParent="true"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/stat_2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:gravity="center_horizontal"
              android:text="243"
              android:textSize="16dp"
              android:textColor="@color/textSecondaryDark"
              android:maxLines="1"/&gt;
  
          &lt;TextView
              android:id="@+id/stat_detail_2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:gravity="center"
              android:text="Calories Burned"
              android:textSize="8sp"
              android:textColor="@color/textSecondary"
              android:maxLines="1"/&gt;
      &lt;/LinearLayout&gt;
  
      &lt;View
          android:id="@+id/divider_2"
          android:layout_width="1dp"
          android:layout_height="38dp"
          android:layout_toRightOf="@+id/stat_2_layout"
          android:background="@drawable/linedivider"/&gt;
  
      &lt;LinearLayout
          android:id="@+id/stat_3_layout"
          android:layout_width="60dp"
          android:layout_height="wrap_content"
          android:layout_marginLeft="12dp"
          android:layout_marginRight="12dp"
          android:layout_toRightOf="@+id/divider_2"
          android:layout_centerVertical="true"
          android:orientation="vertical"&gt;
  
          &lt;TextView
              android:id="@+id/stat_3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:gravity="center_horizontal"
              android:text="3200"
              android:textSize="16dp"
              android:textColor="@color/textSecondaryDark"
              android:maxLines="1"/&gt;
  
          &lt;TextView
              android:id="@+id/stat_detail_3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_gravity="center_horizontal"
              android:gravity="center"
              android:text="Steps"
              android:textSize="8sp"
              android:textColor="@color/textSecondary"
              android:maxLines="1"/&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>