title: ConstraintLayout: place TextView below ImageView
body: <p>I'm faced with the seemingly simple task of having a layout with: </p>
  
  <ul>
  <li>An <code>ImageView</code> taking the full width, height according to image's aspect ratio</li>
  <li>a <code>TextView</code> below that</li>
  </ul>
  
  <p>This is what I have </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:app="http://schemas.android.com/apk/res-auto"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"&gt;
  
      &lt;ImageView
          android:id="@+id/image_view"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginBottom="16dp"
          android:adjustViewBounds="true"
          android:scaleType="fitXY"
          android:src="@drawable/hamster"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"/&gt;
  
      &lt;TextView
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:text="MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText MyText "
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toBottomOf="@id/image_view"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>And this is what it looks like: </p>
  
  <p><a href="https://i.stack.imgur.com/RZNnl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RZNnl.png" alt="enter image description here"></a></p>
  
  <p>As you can see, the <code>ImageView</code> has a margin to the top which I do not want. </p>
  
  <p>If I change the <code>ImageView's</code> constraints from </p>
  
  <pre><code>        app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"
  </code></pre>
  
  <p>to </p>
  
  <pre><code>        app:layout_constraintLeft_toLeftOf="parent"
          app:layout_constraintRight_toRightOf="parent"
          app:layout_constraintTop_toTopOf="parent"
  </code></pre>
  
  <p>(removing the bottom constraint), the result looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/UDfHM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UDfHM.png" alt="enter image description here"></a></p>
  
  <p>Now the <code>ImageView</code> is at the very top of my layout, but the <code>TextView</code> has gone. Mind you, for the second variant, Android Studio 3's layout preview shows the layout exactly as I would want it: </p>
  
  <p><a href="https://i.stack.imgur.com/1QN5p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1QN5p.png" alt="enter image description here"></a></p>
  
  <p>What am I doing wrong and how can I fix it? </p>
  
  <p>Note: The layout needs to be <code>ConstraintLayout</code> and the layout's height has to be <code>wrap_content</code>. </p>
  
  <p>You can find my test project <a href="https://github.com/fweigl/Constraintthrowaway" rel="nofollow noreferrer">here</a>.</p>
  
  <p><strong>EDIT: The problem seems to occur only on larger devices. I'm using the Nexus 9 emulator.</strong> </p>