title: Constraint Layout put view below if there is not enough space horizontally
body: <p>Is anyone aware of how to position the buttons vertically if the button text is too long inside of the xml?</p>
  <p>I want the buttons to be positioned horizontally if they fit, if one of the buttons has to hyphenate, then I would like to avoid that by positioning the buttons below each other. Is there a way to do it inside of the XML only?</p>
  <p>Thanks!</p>
  <p><a href="https://i.stack.imgur.com/my7bt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/my7bt.png" alt="Layout where button text is too long" /></a></p>
  <p><a href="https://i.stack.imgur.com/BlTWv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BlTWv.png" alt="Expected behavior" /></a></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:orientation=&quot;vertical&quot;&gt;
  
      &lt;TextView
          android:id=&quot;@+id/tv_header&quot;
          style=&quot;@style/TitleTextAppearance.WithPrimaryBackground&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;@string/header_enter_startcode&quot; /&gt;
  
      &lt;androidx.constraintlayout.widget.ConstraintLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:background=&quot;@drawable/dialog_background_with_margin&quot;&gt;
  
          &lt;TextView
              android:id=&quot;@+id/tv_status&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:text=&quot;@string/pls_enter_startcode&quot;
              android:textSize=&quot;@dimen/text_size_default&quot;
              android:textAlignment=&quot;center&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;com.google.android.material.textfield.TextInputLayout
              android:id=&quot;@+id/til_startcode&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_margin=&quot;@dimen/grid_2&quot;
              app:helperText=&quot;@string/example_startcode&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@id/tv_status&quot;&gt;
  
              &lt;com.google.android.material.textfield.TextInputEditText
                  android:id=&quot;@+id/tiet_startcode&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:ems=&quot;10&quot;
                  android:inputType=&quot;text&quot;
                  android:maxLines=&quot;1&quot;
                  android:textStyle=&quot;bold&quot; /&gt;
  
          &lt;/com.google.android.material.textfield.TextInputLayout&gt;
  
          &lt;androidx.constraintlayout.widget.Guideline
              android:id=&quot;@+id/gl_middle&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;0dp&quot;
              android:orientation=&quot;vertical&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintGuide_percent=&quot;0.5&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
          &lt;com.google.android.material.button.MaterialButton
              android:id=&quot;@+id/btn_continue&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginStart=&quot;@dimen/grid_2&quot;
              android:layout_marginTop=&quot;@dimen/grid_2&quot;
              android:layout_marginEnd=&quot;@dimen/grid_2&quot;
              android:text=&quot;@string/btn_continue&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toEndOf=&quot;@+id/gl_middle&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/til_startcode&quot; /&gt;
  
          &lt;com.google.android.material.button.MaterialButton
              android:id=&quot;@+id/btn_cancel&quot;
              style=&quot;?materialButtonOutlinedStyle&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginStart=&quot;@dimen/grid_2&quot;
              android:layout_marginTop=&quot;@dimen/grid_2&quot;
              android:layout_marginEnd=&quot;@dimen/grid_2&quot;
              android:text=&quot;@string/cancel&quot;
              app:layout_constraintEnd_toStartOf=&quot;@+id/gl_middle&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/til_startcode&quot; /&gt;
  
      &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>