title: How to set Android ListView's cell height as half of cell width?
body: <p>I am trying to use constraint layout as below. But the aspect ratio is not respected in the actual layout. Instead, the height is actually wrapping the content inside </p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/content"
  
      android:layout_height="0dp"
      android:layout_width="match_parent"&gt; 
  
          &lt;!-- some content inside --&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>I then think it might be because I didn't set <code>width="0dp"</code> (let constraint decide the width). So I tried another way like below. But then the width becomes zero. </p>
  
  <p><strong>What is the correct way of doing it?</strong></p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/content"
  
      android:layout_height="0dp"
      android:layout_width="0dp"
      app:layout_constraintStart_toEndOf="parent"
      app:layout_constraintEnd_toEndOf="parent"&gt; 
  
          &lt;!-- some content inside --&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong>: working solution after inspired by Anddenver 's answer (with modification):</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
      &lt;FrameLayout
          android:background="@android:color/holo_green_dark"
          android:layout_width="0dp"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          android:layout_height="0dp"
          app:layout_constraintDimensionRatio="2:1"&gt;
  
  
  
      &lt;/FrameLayout&gt;
  
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Further Edit:</strong></p>
  
  <p>It seems I need to wrap one more layer of constraint layout for my inner contents .... :</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
      &lt;FrameLayout
          android:background="@android:color/holo_green_dark"
          android:layout_width="0dp"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          android:layout_height="0dp"
          app:layout_constraintDimensionRatio="2:1"&gt;
  
          &lt;android.support.constraint.ConstraintLayout
              android:layout_width="match_parent"
              android:layout_height="match_parent"&gt;
  
  
              &lt;actual contents here..../&gt;
  
          &lt;/android.support.constraint.ConstraintLayout&gt;
  
  
  
  
      &lt;/FrameLayout&gt;
  
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>Or, just remove the <code>FrameLayout</code>, and wrap <code>ConstraintLayout</code> inside a <code>ConstraintLayout</code>:</p>
  
  <pre><code>&lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      xmlns:app="http://schemas.android.com/apk/res-auto"&gt;
  
      &lt;android.support.constraint.ConstraintLayout
          android:background="@android:color/holo_green_dark"
          android:layout_width="0dp"
          app:layout_constraintTop_toTopOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          android:layout_height="0dp"
          app:layout_constraintDimensionRatio="2:1"&gt;
  
  contents here...
  
          &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>