title: Nested Android Views, static header view
body: <p>To make my explanation shorter, I've made this "mockup" of what I'm trying to achieve.
  I'd like to create a reusable header, footer and a generic viewgroup that I can fill with whatever content is required. A ListActivity, GridView... etc.</p>
  
  <p><img src="https://i.stack.imgur.com/loehn.png" alt="alt text"></p>
  
  <p>I've tried a few different approaches thus far with out any luck whatsoever. My first attempt was to write three basic views. A RelativeLayout that would act as a container. I used  to add the header (worked), wrote the GridView (worked) and when trying to attach the footer with include it would never anchor at the bottom of the screen no matter which gravity I was using.</p>
  
  <p>I'm currently attempting to go quite simple to learn android's view system. So, my first baby step. Get a GridView working with images pulled from an Adapter. (Essentially the 'Hello GridViews' demo from the android site - done, works)</p>
  
  <p><img src="https://i.stack.imgur.com/wAVCE.png" alt="alt text"></p>
  
  <p>Next baby step. Try and add a static header above the GridView... catastrophe. I feel like I'm missing an important stepping stone to get this working, any hints in the right direction would be appreciated. I don't quite understand why the LinearLayout containing the Button is pushing the GridView off the screen (it's in the HiearchyViewer) when the height is only "wrap_content" which should be "44dip".</p>
  
  <p><img src="https://i.stack.imgur.com/lXID5.png" alt="alt text"></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
  &gt;
      &lt;LinearLayout
          xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
      &gt;
          &lt;Button
              android:layout_width="fill_parent"
              android:layout_height="44dip"
              android:text="test"
          /&gt;
      &lt;/LinearLayout&gt;
      &lt;GridView xmlns:android="http://schemas.android.com/apk/res/android" 
           android:id="@+id/gridview"
           android:layout_width="fill_parent" 
           android:layout_height="fill_parent"
           android:columnWidth="112dip"
           android:numColumns="auto_fit"
           android:verticalSpacing="0dp"
           android:horizontalSpacing="0dp"
           android:stretchMode="columnWidth"
           android:gravity="center"
      /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>// edit, fixed xml.</p>
  
  <p><strong>EDIT October 25, 2010</strong>: Here's the solution I'm using now. Each activity gets its own view which the activity inflates. The "reusable" views are included with 
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  &gt;
  &lt;include layout="@layout/titlebar" /&gt;
  &lt;ListView
      android:id="@+id/standingsListView"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_weight="1.0"
      android:background="#FFF"
  /&gt;
  &lt;include layout="@layout/ad" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>