title: Animate ViewPager to fill screen in Android
body: <p>So I have a view which looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/YMHPD.png" alt="enter image description here"></p>
  
  <p>What I am trying to achieve is for the entire view to shift up to hide the big image up top when the user scrolls down on the GridView. Basically, if they want to see more of the gridview, the layout scrolls up to increase the gridview size.</p>
  
  <p>However when I actually do this, here is what happens:</p>
  
  <p><img src="https://i.stack.imgur.com/dsbwZ.png" alt="enter image description here"></p>
  
  <p>It works fine, except the GridView doesn't increase in size to fill the new space in the screen, so the lower portion of the window there is all white as you can see.</p>
  
  <p>Here is how I am doing what I have so far:</p>
  
  <pre><code>private void hideHeader(boolean animate) {
      if(animate) {
          AnimatorSet set = new AnimatorSet();
          set.playTogether(
                  ObjectAnimator.ofFloat(mImageHeader, "translationY", -mImageHeader.getHeight()),
                  ObjectAnimator.ofFloat(mShareButton, "translationY", -mImageHeader.getHeight()),
                  ObjectAnimator.ofFloat(mIndicator, "translationY", -mImageHeader.getHeight()),
                  ObjectAnimator.ofFloat(mViewPager, "translationY", -mImageHeader.getHeight())
          );
  
          set.setDuration(700l);
          set.start();
      }
      else {
          //TODO finish
      }
  }
  </code></pre>
  
  <p>As you can probably tell from the code, I'm using a ViewPager. In this case, the GridView is actually a fragment, which is where I first thought my problem was coming from. However, its not the case that the ViewPager is filling the screen and the fragment inside of it is not, rather the ViewPager itself is what is not filling down vertically:</p>
  
  <p><img src="https://i.stack.imgur.com/mF31C.png" alt="enter image description here"></p>
  
  <p>Here is the XML of the parent fragment (which contains the big image, Share button, and viewpager + indicator):</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  android:orientation="vertical"
                  android:background="@android:color/white"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"&gt;
  
      &lt;include android:id="@+id/fp_abf"
               layout="@layout/action_bar_footer"/&gt;
  
      &lt;include android:id="@+id/fp_image_header"
               layout="@layout/widget_image_header"
               android:layout_below="@id/fp_abf"/&gt;
  
      &lt;TextView android:id="@+id/fp_share_button"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:layout_below="@id/fp_image_header"
                android:gravity="center"
                android:background="@drawable/selectable_action_button_grey_to_bit_green"
                android:textSize="14dp"
                android:textColor="@android:color/white"
                android:text="@string/share_caps"/&gt;
  
      &lt;com.viewpagerindicator.TabPageIndicator android:id="@+id/fp_indicator"
                                               android:layout_width="match_parent"
                                               android:layout_height="wrap_content"
                                               android:layout_below="@+id/fp_share_button"
                                               android:background="@color/header_background"/&gt;
  
      &lt;android.support.v4.view.ViewPager android:id="@+id/fp_pager"
                                         android:layout_width="match_parent"
                                         android:layout_height="match_parent"
                                         android:layout_below="@id/fp_indicator"/&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I originally had this as a LinearLayout, but tried to switch it to Relative to see if that would make any difference (it didn't).</p>
  
  <p>As you can see, the ViewPager has a layout_height of "match_parent", which I thought would be sufficient for it to fill all of the space it has available. I think what is happening is that the view isn't being notified that it has more space to work with and therefore redrawing its bounds, but I'm not sure how to trigger that myself.</p>
  
  <p>Does anyone know how to do that (or a better method for me to achieve what I want)? Thanks for reading.</p>