title: Place one button below another in ConstraintLayout if they can't fit on screen
body: <p>I would like to place buttons horizontally on large screens and vertically on small screens (if they can't fit in screen resolution). Can I do it by using ConstraintLayout without creating two layouts in xml which depend on screen resolution?
  I don't know how can I setup "constraints" for that behaviour?</p>
  
  <p><a href="https://i.stack.imgur.com/8RYE7.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8RYE7.gif" alt="NOW IT WORKS LIKE THIS"></a></p>
  
  <p>It is my layout in xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;Button
         android:id="@+id/button5"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="First button"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
         app:layout_constraintRight_toLeftOf="@+id/button3" /&gt;
  
      &lt;Button
         android:id="@+id/button3"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:text="Second button"
         app:layout_constraintTop_toTopOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toRightOf="@+id/button5"
         app:layout_constraintRight_toRightOf="parent" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>