title: Android: Setting View height to 0
body: <p>I have a RelativeLayout that includes three elements:  a TableLayout at the top that contains some controls (layout_alignParentTop = true), a LinearLayout at the bottom (layout_alignParentBottom = true) that contains a couple buttons and a ListView that stretches between them (using layout_below and layout_above the two elements).  That works great, but under certain circumstances, the bottom LinearLayout needs to go away.  If I use setVisibility to set it to View.GONE or set its height to 0 using setLayoutParams(), the ListView is stubbornly refusing to resize to take up the newly freed space.  I've tried calling requestLayout() on basically everything in the hierarchy, and nothing seems to work.  If I fire up the hierarchy viewer, I can see that the view is gone/has layout_height of 0, but it still doesn't work.</p>
  
  <p>Ironically, after the hierarchy viewer is done, the layout corrects itself.  I'm thinking that having my users run hierarchy viewer is probably unacceptable, though.</p>
  
  <p>EDIT:  The middle layout is actually a RelativeLayout containing the ListView, which might matter, I'm going to try and eliminate it.  I've posted a simplified version of my XML that gives an idea of what I'm looking at.</p>
  
  <pre><code>&lt;RelativeLayout
      android:id="@+id/main_container"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"&gt;
      &lt;TableLayout
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:id="@+id/top_table"
          android:layout_alignParentTop="true"
          android:stretchColumns="2"
          android:shrinkColumns="1"&gt;
          &lt;!-- removed for simplicity --&gt;
      &lt;/TableLayout&gt;
      &lt;RelativeLayout
          android:id="@+id/main_content"
          android:descendantFocusability="afterDescendants"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:layout_below="@id/title_table"
          android:layout_above="@id/ad_toolbar"&gt;
          &lt;!-- removed for simplicity --&gt;
          &lt;ListView 
              android:id="@+id/android:list"
              android:layout_alignParentTop="true"
              android:descendantFocusability="afterDescendants"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/RelativeLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/bottom_layout"
          android:orientation="vertical"
          android:layout_alignParentBottom="true"
          android:layout_height="wrap_content"
          android:layout_width="fill_parent"&gt;
          &lt;!-- removed for simplicity --&gt;
      &lt;/LinearLayout&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>