title: Change Fragment's container height dynamically
body: <p>I want to change my container's height (which is <code>PageViewer</code>) from my fragment class on scroll event of my <code>ListView</code>.</p>
  
  <p><strong>What i have tried already</strong> :- </p>
  
  <p>1.LayoutParams</p>
  
  <pre><code>             ViewGroup.LayoutParams params = view1.getLayoutParams();
               params.height = mContainerHeight+ Math.max(a,b);
               view1.requestLayout();
  </code></pre>
  
  <p>Here <code>view1</code> is my container.</p>
  
  <p>2.Getting container directly to my fragment class(by FindViewbById) which failed, because my view was in different(parent) layout and we couldn't get views from different layout.</p>
  
  <p>And many more tweaks based on above implementations.</p>
  
  <p>I may be doing this wrong, So i would like tell you what i want to achieve. My container's height should increase to fill the empty space between <code>Actionbar</code> and my <code>ListView</code>.  when i scroll up container height should increase.</p>
  
  <p>What's happening .<img src="https://i.stack.imgur.com/rdiv4.jpg" alt="Fragment ">
  Action bar is moving up but Container isnt.</p>
  
  <p>I would really appreciate some help.</p>
  
  <p><strong>EDIT 1</strong> CODE</p>
  
  <p>AwesomeCardFragment class</p>
  
  <pre><code>public class AwesomeCardFragment extends Fragment {
  
  private int mActionBarTitleColor;
  private int mActionBarHeight;
  private int mHeaderHeight;
  private int mMinHeaderTranslation;
  private KenBurnsView mHeaderPicture;
  private ImageView mHeaderLogo;
  private View mHeader;
  private View mPlaceHolderView;
  private AccelerateDecelerateInterpolator mSmoothInterpolator;
  
  private int mContainerHeight;
  private int mMinContainerTranslation;
  
  private RectF mRect1 = new RectF();
  private RectF mRect2 = new RectF();
  
  private AlphaForegroundColorSpan mAlphaForegroundColorSpan;
  private SpannableString mSpannableString;
  
  private TypedValue mTypedValue = new TypedValue();
  
  private static final String ARG_POSITION = "position";
  
  // private int position;
  ListView mListView;
  
  ViewPager vp;
  MainActivity ma;
  // Button productButton;
  // static String ARG_POSITION = "position";
  private int position;
  
  // LinearLayout rl;
  
  public static AwesomeCardFragment newInstance(int position) {
      AwesomeCardFragment f = new AwesomeCardFragment();
      Bundle b = new Bundle();
      b.putInt(ARG_POSITION, position);
      f.setArguments(b);
      return f;
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      position = getArguments().getInt(ARG_POSITION);
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      inflater.inflate(R.layout.activity_slide_main, container, false);
  
      FrameLayout fl = new FrameLayout(getActivity());
      fl.setLayoutParams(params);
      final int margin = (int) TypedValue.applyDimension(
              TypedValue.COMPLEX_UNIT_DIP, 8, getResources()
                      .getDisplayMetrics());
  
      mListView = new ListView(getActivity());
      params.setMargins(margin, margin, margin, margin);
      mListView.setLayoutParams(params);
      mListView.setLayoutParams(params);
      mListView.setBackgroundResource(R.drawable.background_card);
      // test
      fl.addView(mListView);
      mSmoothInterpolator = new AccelerateDecelerateInterpolator();
      mHeaderHeight = getResources().getDimensionPixelSize(
              R.dimen.header_height);
      mMinHeaderTranslation = -mHeaderHeight + getActionBarHeight()
              + getActionBarHeight();
  
      mMinContainerTranslation = mMinHeaderTranslation + getActionBarHeight()
              + getActionBarHeight();
      mHeader = getActivity().findViewById(R.id.header);
      mHeaderPicture = (KenBurnsView) getActivity().findViewById(
              R.id.header_picture);
      mHeaderPicture.setResourceIds(R.drawable.picture0, R.drawable.picture1);
      mHeaderLogo = (ImageView) getActivity().findViewById(R.id.header_logo);
  
      mActionBarTitleColor = getResources().getColor(
              R.color.actionbar_title_color);
  
      mSpannableString = new SpannableString(
              getString(R.string.noboringactionbar_title));
      mAlphaForegroundColorSpan = new AlphaForegroundColorSpan(
              mActionBarTitleColor);
      mContainerHeight = container.getHeight();
      setupListView(container);
      return fl;
  }
  
  private void setupListView(final ViewGroup view1) {
      ArrayList&lt;String&gt; FAKES = new ArrayList&lt;String&gt;();
      for (int i = 0; i &lt; 1000; i++) {
          FAKES.add("entry " + i);
      }
  
      mPlaceHolderView = getActivity().getLayoutInflater().inflate(
              R.layout.view_header_placeholder, mListView, false);
  
      // mPlaceHolderView = getActivity().getLayoutInflater().in
      mListView.addHeaderView(mPlaceHolderView);
      mListView.setAdapter(new ArrayAdapter&lt;String&gt;(getActivity(),
              android.R.layout.simple_list_item_1, FAKES));
      mListView.setOnScrollListener(new AbsListView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {
          }
  
          @Override
          public void onScroll(AbsListView view, int firstVisibleItem,
                  int visibleItemCount, int totalItemCount) {
              int scrollY = getScrollY();
               ViewGroup.LayoutParams params = view1.getLayoutParams();
  
          Log.i("wtf", "container height"+mContainerHeight);
  
          params.height = mContainerHeight+ Math.max(-scrollY,
               mMinHeaderTranslation);
  
               Log.i("wtf", "container height changed"+params.height);
  
               view1.requestLayout();
  
               mHeader.setTranslationY(Math.max(-scrollY,
                      mMinHeaderTranslation));
  
              ViewGroup.LayoutParams param = (ViewGroup.LayoutParams) view1
                      .getLayoutParams();
              if (param != null) {
                  param.height = mContainerHeight
                          + Math.max(-scrollY, mMinHeaderTranslation);
  
                  view1.setLayoutParams(param);
              }
  
              // view1.setTranslationY(Math.max(-scrollY,
              // mMinHeaderTranslation));
  
              // header_logo --&gt; actionbar icon
              float ratio = clamp(mHeader.getTranslationY()
                      / mMinHeaderTranslation, 0.0f, 1.0f);
              interpolate(mHeaderLogo, getActionBarIconView(),
                      mSmoothInterpolator.getInterpolation(ratio));
  
              setTitleAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F));
  
          }
      });
  }
  }
  </code></pre>
  
  <p>main xml class which has Container</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;FrameLayout
      android:id="@+id/header"
      android:layout_width="match_parent"
      android:layout_height="@dimen/header_height" &gt;
  
      &lt;com.flavienlaurent.notboringactionbar.KenBurnsView
          android:id="@+id/header_picture"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:src="@drawable/picture0" /&gt;
  
      &lt;ImageView
          android:id="@+id/header_logo"
          android:layout_width="@dimen/header_logo_size"
          android:layout_height="@dimen/header_logo_size"
          android:layout_gravity="center"
          android:src="@drawable/ic_header_logo" /&gt;
  
      &lt;com.astuetz.PagerSlidingTabStrip
          android:id="@+id/tabs"
          android:layout_width="match_parent"
          android:layout_height="48dip"
          android:layout_gravity="bottom"
          android:src="@drawable/background_tabs" /&gt;
  &lt;/FrameLayout&gt;
  
  
  &lt;android.support.v4.view.ViewPager
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_above="@+id/colors"
      android:layout_below="@+id/header"
  
      tools:context=".MainActivity" /&gt;
  
  &lt;LinearLayout
      android:id="@+id/colors"
      android:layout_width="match_parent"
      android:layout_height="48dip"
      android:layout_alignParentBottom="true"
      android:layout_marginBottom="8dip"
      android:layout_marginLeft="4dip"
      android:layout_marginRight="4dip"
      android:orientation="horizontal" &gt;
  
      &lt;ImageView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_margin="4dip"
          android:layout_weight="1"
          android:background="#FF666666"
          android:onClick="onColorClicked"
          android:tag="#FF666666" /&gt;
  
      &lt;ImageView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_margin="4dip"
          android:layout_weight="1"
          android:background="#FF96AA39"
          android:onClick="onColorClicked"
          android:tag="#FF96AA39" /&gt;
  
      &lt;ImageView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_margin="4dip"
          android:layout_weight="1"
          android:background="#FFC74B46"
          android:onClick="onColorClicked"
          android:tag="#FFC74B46" /&gt;
  
      &lt;ImageView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_margin="4dip"
          android:layout_weight="1"
          android:background="#FFF4842D"
          android:onClick="onColorClicked"
          android:tag="#FFF4842D" /&gt;
  
      &lt;ImageView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_margin="4dip"
          android:layout_weight="1"
          android:background="#FF3F9FE0"
          android:onClick="onColorClicked"
          android:tag="#FF3F9FE0" /&gt;
  
      &lt;ImageView
          android:layout_width="0dip"
          android:layout_height="match_parent"
          android:layout_margin="4dip"
          android:layout_weight="1"
          android:background="#FF5161BC"
          android:onClick="onColorClicked"
          android:tag="#FF5161BC" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p></p>