title: Android list view wrap content until a certain size based on footer size
body: <p>I am working on an android application.</p>
  
  <p>In an XML Layout I need to do the following:</p>
  
  <p>I have a list view at the top (listViewProducts) , and another Relative view under it (receiptSection). </p>
  
  <p>The list view should take as much space as it has items. And the rest is taken by the receiptSection.</p>
  
  <p>So for example if I have 2 items in the listViewProducts:</p>
  
  <p><img src="https://i.stack.imgur.com/qPXmD.png" alt="first image"></p>
  
  <p>The list view is as big as the 2 items and the rest is taken by the receiptView.</p>
  
  <p>If I add another item, the list view now take more space and push the receiptView lower:</p>
  
  <p><img src="https://i.stack.imgur.com/I7MrT.png" alt="enter image description here"></p>
  
  <p>However if I add a lot more items, I want the list view height to stop growing to leave a minimum height for the receiptView that cannot go smaller:</p>
  
  <p><img src="https://i.stack.imgur.com/TDf2z.png" alt="enter image description here"></p>
  
  <p>As you see in the picture, the receiptVIew has a minimum height of 50dp. once the receipt view get to that height, it should stop shrinking and now the list view has a fixed size based on the remaining of the space. The rest will be scrollable.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>I created a list view. I have <code>android:layout_alignParentTop="true"</code> and <code>android:layout_height="wrap_content"</code>.</p>
  
  <p>This will make it grow with its content and its at the top of the view</p>
  
  <pre><code>&lt;ListView
      android:id="@+id/listViewProducts"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true" &gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>THen I created a RelativeLayout that will hold the checkout_receipt_view that is in a seperate xml layout file.</p>
  
  <p>For this view I have <code>android:layout_alignParentBottom="true"</code> and <code>android:layout_below="@id/listViewProducts"</code> that will make it go under the list view and align with the bottom of the view.</p>
  
  <p>I also used <code>android:minHeight="50d"</code> in order to set the minimum height of the receiptSection.</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/receiptSection"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentBottom="true"
      android:layout_below="@id/listViewProducts"
      android:minHeight="50dp" &gt;
      &lt;include layout="@layout/checkout_receipt_view" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The listViewProducts is growing with the items, and the receiptView is taking the remaining space correctly.</p>
  
  <p><strong>The problem</strong>
  however the minimum height did not work. The list view keeps on growing infinitely and the receiptSection will be pushed out of the view.</p>
  
  <p>Is there a way I can make the listView stop growing when the receiptView reaches 50dp?</p>
  
  <p>Thanks a lot for any help.</p>