title: Android RelativeLayout and height of wrap_content?
body: <p>I am trying to make a selection ListActivity, similar to the one used to add shortcuts to the launcher screens. I have rolled my own header and footers, which I would like to be "sticky" at the top and bottom of the view when on screen. In order to do this, I am using a RelativeLayout with the header set to dock to top, footer set to dock to bottom, and the list set to go below the header and above the footer. In terms of the overall layout of the activity, this is rendering as I would expect. The header is sticky to the top, the footer is sticky to the bottom, and the list scrolls in between them. </p>
  
  <p>One odd thing though happened when I switched to the RelativeLayout as my root. Please see the following screenshot: </p>
  
  <p><img src="https://i.stack.imgur.com/bUCAb.png" alt="enter image description here"></p>
  
  <p>I want my Activity's height to be <code>wrap_content</code>, so that the form is only as high as the content displayed in it, but once i switched to RelativeLayout, it seems to render the Activity effectively as <code>fill_parent</code>, taking up the whole screen, even though the content doesn't warrant it. Notice that there are not enough list items to fill the screen, which with the <code>fill_parent</code> style, is leaving a bunch of whitespace between the end of the list, and the footer. I was setting my height's via styles - which worked fine with LinearLayout, but seems to be ignored now. So I tried hard-coding the height directly on the RelativeLayout, but it still doesn't work and still renders as <code>fill_parent</code>. </p>
  
  <p>Here is my layout code: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
                      style="@style/GroupsList"  
                      android:layout_height="wrap_content"&gt;
  
          &lt;FrameLayout android:layout_height="wrap_content" 
                       android:layout_width="fill_parent" 
                       android:id="@+id/hdrGroups" 
                       android:layout_alignParentTop="true"&gt;
              &lt;include layout="@layout/title" 
                       android:layout_width="fill_parent" 
                       android:layout_height="wrap_content"&gt;
              &lt;/include&gt;
          &lt;/FrameLayout&gt;
  
          &lt;FrameLayout style="@style/MyFooter" 
                       android:layout_height="wrap_content" 
                       android:layout_width="fill_parent" 
                       android:layout_alignParentBottom="true" 
                       android:id="@+id/ftrGroups"&gt;
              &lt;ImageView style="@style/CloseButton" 
                         android:layout_height="wrap_content" 
                         android:layout_width="wrap_content" 
                         android:src="@drawable/add" 
                         android:id="@+id/imgGroupsAdd" 
                         android:clickable="true"&gt;
              &lt;/ImageView&gt;
          &lt;/FrameLayout&gt;
  
          &lt;ListView android:divider="#9f9f9f" 
                    android:id="@+id/android:list" 
                    android:choiceMode="singleChoice" 
                    android:dividerHeight="1dp" 
                    android:layout_height="wrap_content" 
                    android:layout_width="fill_parent" 
                    android:layout_below="@id/hdrGroups" 
                    android:layout_above="@id/ftrGroups"&gt;
          &lt;/ListView&gt;
  
          &lt;TextView android:text="@string/browser_no_groups" 
                    style="@style/ListedItemB" 
                    android:id="@+id/android:empty" 
                    android:layout_height="wrap_content" 
                    android:layout_above="@id/ftrGroups" 
                    android:layout_below="@id/hdrGroups" 
                    android:layout_width="fill_parent"&gt;
          &lt;/TextView&gt;
      &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>All layout is done via XML, ... I am not doing any layout in code. 
  How can I get the sticky header and footer while also having the activity as a whole behave in a <code>wrap_content</code> mode for its height? Is there some other way I should be going about this instead of a RelativeLayout?</p>