title: How can i set ViewPager's height programatically more than one time?
body: <p>I can set ViewPager's height programatically by using <code>vpTabs.getLayoutParams().height = DESIRED_SIZE;</code> but it works only once at run time. now the question is how to set the height more than one time at runtime ?</p>
  
  <p><strong>activity_layout.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/rlActivityProfile"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.my.package.ProfileActivity"&gt;
  
      &lt;!--MainContainer--&gt;
      &lt;com.my.package.widget.ScrollViewX
          android:id="@+id/svxUserProfile"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"&gt;
  
          &lt;!--Main Container--&gt;
          &lt;RelativeLayout
  
              android:layout_width="match_parent"
              android:layout_height="wrap_content"&gt;
              &lt;!--Header--&gt;
              &lt;RelativeLayout
                  android:id="@+id/rlProfileBanner"
                  android:layout_width="match_parent"
                  android:layout_height="300dp"
                  android:background="@color/listile_green"&gt;
  
                      &lt;!-- SOME OTHER VIEW--&gt;
  
              &lt;/RelativeLayout&gt;
  
              &lt;RelativeLayout
                  android:id="@+id/rlTabs"
                  android:layout_below="@id/rlProfileBanner"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"&gt;
  
                  &lt;!--Slider--&gt;
                  &lt;android.support.v4.view.ViewPager
                      android:id="@+id/vpTabs"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"
                      android:layout_below="@id/stlControl" /&gt;
  
              &lt;/RelativeLayout&gt;
  
          &lt;/RelativeLayout&gt;
  
  
      &lt;/com.my.package.widget.ScrollViewX&gt;
  
  
      &lt;!--Transparent toolbar--&gt;
      &lt;include
          android:id="@+id/iAppBar"
          layout="@layout/app_bar" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>The viewPager is initialized in onCreate() of MainActivity class</p>
  
  <pre><code>ViewPager vpTabs = (ViewPager) findViewById(R.id.vpTabs);
  </code></pre>
  
  <p>I am changing the viewPager's height from fragment using an interface like this </p>
  
  <pre><code>//Calling from fragment
  int totalHeight = titles.length * EditProfileAdapter.ROW_HEIGHT;
  vpListener.onViewPagerHeightChange(totalHeight);
  </code></pre>
  
  <p>in MainActivity </p>
  
  <pre><code>@Override
      public void onViewPagerHeightChange(int height) {
          RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
          params.height = height; //left, top, right, bottom
          vpTabs.setLayoutParams(params);
      }
  </code></pre>
  
  <p>NOTE: The custom widget <code>ScrollViewX</code> is the same ScrollView but with a Custom ScrollListener. </p>