title: How to wrap the height of a ViewPager to the height of its current Fragment?
body: <p>I made a ScrollView containing a ViewPager, but the ViewPager does not grow in height. When the content inside the ViewPager is too big, it get 'pucht'(?) inside, the table is the space that shrinks.</p>
  
  <p>I have search for a solution and found that the problem is the <code>wrap_content</code>, when the ViewPager is loaded there is no content. So the ViewPager keeps the screen height. The solutions that I found are not for <code>FragmentPagerAdapter</code>, so i have edit this question.</p>
  
  <p>Please point me in the right direction.</p>
  
  <p>Greetings, Christophe VD.</p>
  
  <p>The main layout is this, the timetable on the bottom is one of the problems:<br />
  <a href="https://i.stack.imgur.com/8f5Xq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8f5Xq.png" alt="enter image description here"></a><br />
  It needs more like this:<br />
  <a href="https://i.stack.imgur.com/ceH63.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ceH63.png" alt="enter image description here"></a></p>
  
  <p>The FragmentPagerAdapter is:</p>
  
  <pre><code>import android.content.Context;
  import android.graphics.pdf.PdfDocument;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class film_tabs_adapter extends FragmentPagerAdapter {
      private final String[] TITLES = { "Info", "Comment", "Cast", "Muziek"};
      String[] Film_Data;
  
      public film_tabs_adapter(FragmentManager fm, String[] Film_Data_in) {
          super(fm);
          Film_Data = Film_Data_in;
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return TITLES[position];
      }
  
  
      @Override
      public int getCount() {
          return 4;
      }
  
      @Override
      public Fragment getItem(int position) {
          Fragment fragment =null;
          Bundle bundle = new Bundle();
          bundle.putStringArray("Film_Data", Film_Data);
          switch(position) {
              case 0:
                  //return new film_info();
                  fragment = new film_info();
                  fragment.setArguments(bundle);
                  return fragment;
              case 1:
                  return new film_coment();
              case 2:
                  return new film_cast();
              case 3:
                  return new film_sound();
              default:
                  return new film_info();
          }
      }
  
  }
  </code></pre>
  
  <p><br />
  And the class of the Fragment:<br /></p>
  
  <pre><code>    import android.content.Context;
  import android.graphics.Color;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.util.Log;
  import android.view.Gravity;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TableLayout;
  import android.widget.TableRow;
  import android.widget.TextView;
  
  public class film_info extends Fragment {
      TextView label_locatie;
      ...
      TableLayout TimeTabel;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View view = inflater.inflate(R.layout.activity_film_info, container, false); // layout (activity_film_info) openen
          Context context = inflater.getContext();
          DatabaseVerwerker DB = new DatabaseVerwerker(context);
          String[] Film_Data =  getArguments().getStringArray("Film_Data");
          ...
          return view;
      }
  
  }
  </code></pre>
  
  <p>The Activity:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:fillViewport="true"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="vertical"&gt;
  
          &lt;FrameLayout
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginBottom="5dp"
              android:id="@+id/header"&gt;
  
              &lt;FrameLayout
                  android:layout_width="match_parent"
                  android:layout_height="120dp"&gt;
  
                  &lt;ProgressBar
                      style="?android:attr/progressBarStyleHorizontal"
                      android:progressDrawable="@drawable/redprogressbar"
                      android:layout_width="match_parent"
                      android:layout_height="2dp"
                      android:id="@+id/DownloadCover"
                      android:layout_gravity="top" /&gt;
  
                  &lt;ImageView
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:id="@+id/FilmCover"
                      android:src="@drawable/cover"
                      android:adjustViewBounds="true"
                      android:padding="-5dp"
                      android:scaleType="centerCrop" /&gt;
  
              &lt;/FrameLayout&gt;
  
              &lt;FrameLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_gravity="left|right|top"
                  android:paddingLeft="7dp"&gt;
  
                  &lt;LinearLayout
                      android:orientation="horizontal"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"&gt;
  
                      &lt;TableRow
                          android:layout_width="wrap_content"
                          android:layout_height="match_parent"&gt;
  
                          &lt;ImageView
                              android:layout_width="82dp"
                              android:layout_height="120dp"
                              android:id="@+id/FilmPoster"
                              android:src="@drawable/poster_x"
                              android:adjustViewBounds="true"
                              android:layout_gravity="bottom|left" /&gt;
                      &lt;/TableRow&gt;
  
                      &lt;TableRow
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"&gt;
  
                          &lt;TextView
                              android:layout_width="match_parent"
                              android:layout_height="wrap_content"
                              android:text="New Text"
                              android:id="@+id/FilmTitel"
                              android:textStyle="bold"
                              android:gravity="center_horizontal"
                              android:layout_marginTop="120dp" /&gt;
                      &lt;/TableRow&gt;
                  &lt;/LinearLayout&gt;
  
              &lt;/FrameLayout&gt;
  
          &lt;/FrameLayout&gt;
  
          &lt;FrameLayout
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:id="@+id/body"&gt;
              &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                  xmlns:tools="http://schemas.android.com/tools"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  tools:context=".MainActivity" &gt;
  
                  &lt;com.astuetz.PagerSlidingTabStrip
                      android:id="@+id/tabs"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:background="#dadada"
                      app:pstsShouldExpand="true"
                      app:pstsDividerColor="#EDEDED"
                      app:pstsIndicatorColor="#C3263E"
                      app:pstsDividerPadding="10dp"
                      app:pstsIndicatorHeight="4dp"
                      app:pstsTabPaddingLeftRight="0dp"
                      /&gt;
  
                  &lt;android.support.v4.view.ViewPager
                      android:id="@+id/pager"
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:layout_below="@+id/tabs"
                      tools:context=".MainActivity"
                      android:soundEffectsEnabled="false" /&gt;
  
              &lt;/RelativeLayout&gt;
          &lt;/FrameLayout&gt;
      &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>The Fragment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;FrameLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="999dp"&gt;
  
          &lt;LinearLayout
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="5dp"&gt;
  
              &lt;FrameLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:paddingBottom="5dp"
                  android:background="#dadada"&gt;
  
                  &lt;TableLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:stretchColumns="*"&gt;
  
                      &lt;TableRow
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="0dp"
                              android:layout_height="wrap_content"
                              android:layout_weight="1"
                              android:layout_margin="4dp"&gt;
  
                              &lt;ImageView
                                  android:layout_alignParentLeft="true"
                                  android:layout_alignParentTop="true"
                                  android:layout_width="30dp"
                                  android:layout_height="32dp"
                                  android:id="@+id/imageView3"
                                  android:src="@drawable/icon_locatie"
                                  android:layout_margin="2dp" /&gt;
  
                              &lt;TextView
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBottom="@+id/imageView3"
                                  android:layout_alignTop="@+id/imageView3"
                                  android:layout_toRightOf="@+id/imageView3"
                                  android:gravity="center_vertical"
                                  android:text="Small Text"
                                  android:id="@+id/label_locatie" /&gt;
  
                          &lt;/RelativeLayout &gt;
  
                          &lt;RelativeLayout
                              android:layout_width="0dp"
                              android:layout_height="wrap_content"
                              android:layout_weight="1"
                              android:layout_margin="4dp"&gt;
  
                              &lt;ImageView
                                  android:layout_alignParentLeft="true"
                                  android:layout_alignParentTop="true"
                                  android:layout_width="30dp"
                                  android:layout_height="32dp"
                                  android:id="@+id/imageView4"
                                  android:src="@drawable/icon_speelduur"
                                  android:layout_margin="2dp" /&gt;
  
                              &lt;TextView
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBottom="@+id/imageView4"
                                  android:layout_alignTop="@+id/imageView4"
                                  android:layout_toRightOf="@+id/imageView4"
                                  android:gravity="center_vertical"
                                  android:text="Small Text"
                                  android:id="@+id/label_speelduur" /&gt;
                          &lt;/RelativeLayout&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="0dp"
                              android:layout_height="wrap_content"
                              android:layout_weight="1"
                              android:layout_margin="4dp"&gt;
  
                              &lt;ImageView
                                  android:layout_alignParentLeft="true"
                                  android:layout_alignParentTop="true"
                                  android:layout_width="30dp"
                                  android:layout_height="32dp"
                                  android:id="@+id/imageView5"
                                  android:src="@drawable/icon_genre"
                                  android:layout_margin="2dp" /&gt;
  
                              &lt;TextView
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBottom="@+id/imageView5"
                                  android:layout_alignTop="@+id/imageView5"
                                  android:layout_toRightOf="@+id/imageView5"
                                  android:gravity="center_vertical"
                                  android:text="Small Text"
                                  android:id="@+id/label_genre" /&gt;
                          &lt;/RelativeLayout&gt;
                      &lt;/TableRow&gt;
  
                      &lt;TableRow
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="0dp"
                              android:layout_height="match_parent"
                              android:layout_weight="1"
                              android:layout_margin="4dp"&gt;
  
                              &lt;ImageView
                                  android:layout_alignParentLeft="true"
                                  android:layout_alignParentTop="true"
                                  android:layout_width="30dp"
                                  android:layout_height="32dp"
                                  android:id="@+id/imageView6"
                                  android:src="@drawable/icon_gesproken"
                                  android:layout_margin="2dp" /&gt;
  
                              &lt;TextView
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBottom="@+id/imageView6"
                                  android:layout_alignTop="@+id/imageView6"
                                  android:layout_toRightOf="@+id/imageView6"
                                  android:gravity="center_vertical"
                                  android:text="Small Text"
                                  android:id="@+id/label_gesproken" /&gt;
                          &lt;/RelativeLayout&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="0dp"
                              android:layout_height="match_parent"
                              android:layout_weight="1"
                              android:layout_margin="4dp"&gt;
  
                              &lt;ImageView
                                  android:layout_alignParentLeft="true"
                                  android:layout_alignParentTop="true"
                                  android:layout_width="30dp"
                                  android:layout_height="32dp"
                                  android:id="@+id/imageView7"
                                  android:src="@drawable/icon_versie"
                                  android:layout_margin="2dp" /&gt;
  
                              &lt;TextView
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBottom="@+id/imageView7"
                                  android:layout_alignTop="@+id/imageView7"
                                  android:layout_toRightOf="@+id/imageView7"
                                  android:gravity="center_vertical"
                                  android:text="Small Text"
                                  android:id="@+id/label_versie" /&gt;
                          &lt;/RelativeLayout&gt;
  
                          &lt;RelativeLayout
                              android:layout_width="0dp"
                              android:layout_height="match_parent"
                              android:layout_weight="1"
                              android:layout_margin="4dp"&gt;
  
                              &lt;ImageView
                                  android:layout_alignParentLeft="true"
                                  android:layout_alignParentTop="true"
                                  android:layout_width="30dp"
                                  android:layout_height="32dp"
                                  android:id="@+id/imageView8"
                                  android:src="@drawable/icon_ondertiteling"
                                  android:layout_margin="2dp" /&gt;
  
                              &lt;TextView
                                  android:layout_width="match_parent"
                                  android:layout_height="wrap_content"
                                  android:layout_alignBottom="@+id/imageView8"
                                  android:layout_alignTop="@+id/imageView8"
                                  android:layout_toRightOf="@+id/imageView8"
                                  android:gravity="center_vertical"
                                  android:text="Small Text"
                                  android:id="@+id/label_ondertiteling" /&gt;
                          &lt;/RelativeLayout&gt;
                      &lt;/TableRow&gt;
  
                      &lt;TableRow
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"&gt;&lt;/TableRow&gt;
                  &lt;/TableLayout&gt;
              &lt;/FrameLayout&gt;
  
              &lt;FrameLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:paddingLeft="7dp"
                  android:paddingRight="7dp"&gt;
  
                  &lt;TextView
                      android:layout_width="fill_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/label_beschrijving"
                      android:layout_marginBottom="16dp"
                      android:textSize="14sp"
                      android:text="@string/film_FilmBeschrijving" /&gt;
              &lt;/FrameLayout&gt;
  
              &lt;FrameLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:paddingLeft="7dp"
                  android:paddingRight="7dp"&gt;
  
                  &lt;TableLayout
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:id="@+id/timetabel"
                      android:stretchColumns="*"
                      android:shrinkColumns="*"
                      android:background="@drawable/tb_body" /&gt;
              &lt;/FrameLayout&gt;
          &lt;/LinearLayout&gt;
      &lt;/FrameLayout&gt;
  </code></pre>