title: How do I make a FrameLayout fill the height of its parent so the whole page scrolls together?
body: <p>I have a <code>FrameLayout</code> that loads <code>Fragments</code> by tapping on tabs in a <code>TabWidget</code>. I can't figure out how to make the height of the <code>FrameLayout</code> as tall as its content, so that the whole containing <code>ScrollView</code> will scroll together as one instead of a separate scrolling view.</p>
  
  <p>Here's a visual example of this <code>Fragment</code>'s structure:</p>
  
  <p><img src="https://i.stack.imgur.com/wqkC0.png" alt="enter image description here"></p>
  
  <p>As you can see, the Frame Layout Visible Height only reveals one row of the Fragment, when in fact, there are a few. I can scroll within the <code>FrameLayout</code> to see the other rows as it is now, but that's not what I'm going for. The <code>FrameLayout</code> is made up of a <code>LinearLayout</code> containing a <code>GridView</code> with their <code>layout_height</code>s set to <code>wrap_content</code>.</p>
  
  <p>I tried hardcoding the height of the <code>FrameLayout</code> to something like 500dp and it works great except for the fact that it's no longer dynamically sized. Would I need to resize the <code>FrameLayout</code> programmatically each time a new image is loaded into the inner content? Is there a layout attribute I can set so it'll stretch its height to match its inner content?</p>
  
  <p>Here's my layout xml file:</p>
  
  <pre><code>&lt;ScrollView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  &gt;
  &lt;LinearLayout
      android:orientation="vertical"
  
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"&gt;
      &lt;RelativeLayout
          android:layout_width="fill_parent"
          android:layout_height="200dp"&gt;
          &lt;!-- CONTAINS USER INFO AND STATS --&gt;
      &lt;/RelativeLayout&gt;
      &lt;android.support.v4.app.FragmentTabHost
          android:id="@android:id/tabhost"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"&gt;
          &lt;LinearLayout
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="#ffffff"&gt;
              &lt;TabWidget
                  android:id="@android:id/tabs"
                  android:layout_width="fill_parent"
                  android:layout_height="60dp"
                  android:weightSum="2"&gt;
              &lt;/TabWidget&gt;
              &lt;FrameLayout
                  android:id="@android:id/tabcontent"
                  android:layout_width="fill_parent"
                  android:layout_height="wrap_content"
                  &gt;
              &lt;/FrameLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/android.support.v4.app.FragmentTabHost&gt;
  &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>Thank you!</p>
  
  <hr>
  
  <p>Since I'm going to set a bounty on this, I thought I'd share what I've figured out so far. </p>
  
  <p>In the thumbnails, <code>onSuccess</code> when each image is loaded, I'm calling a function in the <code>GridLayout</code> that holds the images that counts the images and sets the height of the <code>GridLayout</code>. This works fine, although it seems like it'd be a bit inefficient. </p>
  
  <p>What I'm doing is setting the <code>GridLayout</code> height and then calling <code>requestLayout</code> and <code>invalidate</code> on it and it's parent(s). This works, but not as the images loading. It'll work if I go to a different tab and return to the thumbnails, oddly enough. Which makes me think I'm not updating at the right time or on the right object.</p>
  
  <p>Anyway, that said. Does anyone know how to make the height of a <code>GridLayout</code> expand to hold its contents (instead of scrolling) so I can scroll the entire page (including the top section)?</p>
  
  <hr>
  
  <p>I should also add the <code>GridView</code> layout:</p>
  
  <pre><code>&lt;GridView
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/grid"
  android:stretchMode="columnWidth"
  android:gravity="center"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:drawSelectorOnTop="false"
  android:fastScrollAlwaysVisible="false"
  android:fastScrollEnabled="false"
  android:numColumns="3"
  android:choiceMode="none"&gt;
  &lt;/GridView&gt;
  </code></pre>