title: How to anchor buttons at the bottom of the layout?
body: <p>I'd like the <code>OK</code> / <code>Cancel</code> buttons to be anchored at the bottom (even when there's more items on the list that can be shown on the screen). Here's what it currently looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/tFJAR.png" alt="enter image description here"></p>
  
  <p>The buttons are on the top, not on the bottom.</p>
  
  <p><strong>The layout that contains the buttons:</strong></p>
  
  <pre><code>&lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
               android:orientation="horizontal"
               android:layout_width="fill_parent"
               android:layout_height="fill_parent"
               android:stretchColumns="true"
               android:id="@+id/buttons_layout"&gt;    
      &lt;TableRow&gt;    
          &lt;Button
              android:id="@+id/btnOK"
              android:background="@color/pomegranate"
              android:text="OK"
              android:layout_gravity="fill_horizontal"
              android:layout_weight="1"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"/&gt;        
          &lt;Button
              android:id="@+id/btnCancel"
              android:background="@color/wet_asphalt"
              android:text="Cancel"
              android:layout_weight="1"
              android:layout_gravity="fill_horizontal"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"/&gt;
      &lt;/TableRow&gt;
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p><strong>The composite layout:</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"&gt;
      &lt;ListView android:id="@+id/options_list"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"&gt;
      &lt;/ListView&gt;
      &lt;include layout="@id/buttons_layout"
               android:layout_alignParentBottom="true"
               android:layout_height="match_parent"
               android:layout_below="@id/options_list"/&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I followed the guidelines I read on <a href="http://developer.android.com/guide/topics/ui/layout/relative.html" rel="nofollow noreferrer">http://developer.android.com/guide/topics/ui/layout/relative.html</a> </p>
  
  <p>I tried this answer - <a href="https://stackoverflow.com/a/6285438/168719">https://stackoverflow.com/a/6285438/168719</a> - it hasn't helped me.</p>
  
  <p>I suspected that it might not work because the list view doesn't "know" how tall it is, so the button layout doesn't know where to place itself, either. But I ruled it out by setting the ListView height to an arbitrary value like 100dp. The buttons are still superimposed over it.</p>
  
  <p>I fiddled with all the layout attributes, but I can't get it to work.</p>
  
  <p>Apart from the solution, I would also like to know why mine doesn't work...</p>