How to remove empty white space at the bottom of CoordinatorLayout with NestedScrollView
<p>I am working with <code>CoordinatorLayout</code> in which i am using <code>AppbarLayout</code> along with <code>ViewPager</code>, <code>Nestedscrollview</code> and <code>TabLayout</code>. On scroll of layout <code>AppbarLayout</code> folds and unfolds.</p>

<p>Now the issue is that onscroll of this layout it leaves empty white space at bottom which I don't want. </p>

<p><strong>Here is my Drawer-Layout:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawerLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"&gt;

    &lt;RelativeLayout
        android:id="@+id/frame_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"&gt;

        &lt;FrameLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;

            &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/coordinator"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:fitsSystemWindows="true"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;

                &lt;android.support.design.widget.AppBarLayout
                    android:id="@+id/app_bar"
                    android:layout_width="match_parent"
                    android:layout_height="220dp"
                    android:background="@drawable/offer_image"
                    android:fitsSystemWindows="true"
                    android:theme="@style/AppTheme.AppBarOverlay"
                    app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;
                    &lt;!--    &lt;com.flaviofaria.kenburnsview.KenBurnsView
                            android:id="@+id/image"
                            android:layout_width="match_parent"
                            android:layout_height="220dp"
                            android:src="@drawable/offer_image" /&gt;--&gt;
                    &lt;android.support.design.widget.CollapsingToolbarLayout
                        android:id="@+id/toolbar_layout"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:fitsSystemWindows="true"
                        app:expandedTitleMarginEnd="64dp"
                        app:expandedTitleMarginStart="48dp"
                        app:layout_scrollFlags="scroll|exitUntilCollapsed"&gt;


                        &lt;com.flaviofaria.kenburnsview.KenBurnsView
                            android:id="@+id/image"
                            android:layout_width="match_parent"
                            android:layout_height="220dp"
                            android:src="@drawable/offer_image" /&gt;

                        &lt;FrameLayout
                            android:id="@+id/collapse_frame"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="#B3c85a00"&gt;

                        &lt;/FrameLayout&gt;

                        &lt;FrameLayout
                            android:id="@+id/centerCircle"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"&gt;

                            &lt;ImageView
                                android:id="@+id/imageViewCenter"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center" /&gt;
                        &lt;/FrameLayout&gt;


                        &lt;android.support.design.widget.TabLayout
                            android:id="@+id/tabs"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_gravity="bottom"
                            android:layout_marginBottom="15dp"
                            app:tabIndicatorColor="#FFFFFF"
                            app:tabMode="scrollable" /&gt;
                        &lt;!--&lt;/FrameLayout&gt;--&gt;
                    &lt;/android.support.design.widget.CollapsingToolbarLayout&gt;
                &lt;/android.support.design.widget.AppBarLayout&gt;

                &lt;!--&lt;FrameLayout--&gt;

                &lt;!--android:layout_width="match_parent"--&gt;
                &lt;!--android:layout_height="match_parent"--&gt;
                &lt;!-- --&gt;
                &lt;!--android:visibility="visible"&gt;--&gt;

                &lt;android.support.design.widget.FloatingActionButton
                    android:id="@+id/fab"
                    style="@style/floating_action_button"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom|end"
                    android:src="@drawable/ic_share_white_24dp"
                    android:visibility="gone"
                    app:backgroundTint="#FF9800"
                    app:elevation="6dp"
                    app:pressedTranslationZ="12dp" /&gt;

                &lt;android.support.v4.view.ViewPager

                    xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/pager_pre"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_gravity="left|bottom|fill_vertical"
                    android:layout_marginTop="0dp"
                    app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;

                &lt;/android.support.v4.view.ViewPager&gt;


            &lt;/android.support.design.widget.CoordinatorLayout&gt;

            &lt;RelativeLayout
                android:id="@+id/bannerView"
                android:layout_width="match_parent"
                android:layout_height="58dp"
                android:layout_gravity="bottom|center"
                android:background="@drawable/curved_white_with_blue_border"
                android:visibility="gone"&gt;

                &lt;TextView
                    android:id="@+id/bannerText"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_centerHorizontal="true"
                    android:layout_centerInParent="true"
                    android:layout_centerVertical="true"
                    android:gravity="center"
                    android:padding="3dp"
                    android:text="Banner"
                    android:visibility="gone" /&gt;

                &lt;ImageView
                    android:id="@+id/bannerImage"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_alignParentLeft="true"
                    android:layout_centerHorizontal="true"
                    android:layout_centerVertical="true"
                    android:gravity="center"
                    android:padding="3dp"
                    android:scaleType="fitXY"
                    android:visibility="gone" /&gt;

                &lt;ImageView
                    android:id="@+id/bannerClose"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentRight="true"
                    android:layout_alignParentTop="true"
                    android:layout_centerVertical="true"
                    android:src="@drawable/cross_icon" /&gt;
            &lt;/RelativeLayout&gt;


            &lt;LinearLayout
                android:id="@+id/socialTabs"
                android:layout_width="match_parent"
                android:layout_height="46dp"
                android:layout_gravity="bottom|center"
                android:layout_marginBottom="5dp"
                android:background="@color/White"
                android:orientation="horizontal"
                android:visibility="gone"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:adjustViewBounds="true"
                    android:src="@drawable/follow" /&gt;

                &lt;FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:layout_gravity="center"
                    android:background="@color/White"&gt;

                    &lt;LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="46dp"
                        android:layout_gravity="center"
                        android:gravity="center"
                        android:paddingLeft="10dp"
                        android:paddingRight="10dp"
                        android:weightSum="3"&gt;

                        &lt;ImageView
                            android:id="@+id/facebookImageView"
                            android:layout_width="30dp"
                            android:layout_height="30dp"
                            android:layout_weight="1"
                            android:src="@drawable/fb_follow" /&gt;

                        &lt;ImageView
                            android:id="@+id/googlePlusImageView"
                            android:layout_width="30dp"
                            android:layout_height="30dp"
                            android:layout_marginLeft="5dp"
                            android:layout_marginRight="5dp"
                            android:layout_weight="1"
                            android:adjustViewBounds="true"
                            android:src="@drawable/google_follow" /&gt;

                        &lt;ImageView
                            android:id="@+id/twitterImageView"
                            android:layout_width="30dp"
                            android:layout_height="30dp"
                            android:layout_weight="1"
                            android:adjustViewBounds="true"
                            android:src="@drawable/twitter_follow" /&gt;
                    &lt;/LinearLayout&gt;
                &lt;/FrameLayout&gt;
            &lt;/LinearLayout&gt;
        &lt;/FrameLayout&gt;

        &lt;android.support.design.widget.CoordinatorLayout
            android:id="@+id/snackbarCoordinatorLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"&gt;

        &lt;/android.support.design.widget.CoordinatorLayout&gt;
    &lt;/RelativeLayout&gt;

    &lt;ExpandableListView
        android:id="@+id/left_drawer"
        android:layout_width="265dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#fff"
        android:choiceMode="singleChoice"
        android:divider="@null"
        android:dividerHeight="0dp"
        android:drawSelectorOnTop="true"
        android:groupIndicator="@null"
        android:scrollbars="@null" /&gt;
    &lt;!--    &lt;FrameLayout xmlns:tools="http://schemas.android.com/tools"
            android:id="@+id/container"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:ignore="MergeRootFrame"&gt;&lt;/FrameLayout&gt;--&gt;

&lt;/android.support.v4.widget.DrawerLayout&gt;
</code></pre>

<p><strong>NestedScrollView's code:</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_vertical"
    android:fillViewport="true"
    android:fitsSystemWindows="true"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;


    &lt;RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/fragment_back_color"
            android:orientation="vertical"&gt;


            &lt;LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:padding="5dp"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:background="@drawable/new_recharge" /&gt;

                &lt;com.spiceladdoo.views.RobotTextviewRegular
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:text="NEW PAYMENT"
                    android:textColor="@color/offer_name_text_color" /&gt;

            &lt;/LinearLayout&gt;


            &lt;RelativeLayout

                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:background="@color/white"
                android:paddingBottom="20dp"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:paddingTop="20dp"&gt;

                &lt;HorizontalScrollView
                    android:id="@+id/hsv"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:fillViewport="true"
                    android:measureAllChildren="false"
                    android:scrollbars="none"&gt;

                    &lt;LinearLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerInParent="true"
                        android:orientation="horizontal"&gt;

                        &lt;LinearLayout
                            android:id="@+id/wallet_layout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="vertical"&gt;

                            &lt;ImageView
                                android:id="@+id/wallet_recharge"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/wallet_recherge" /&gt;

                            &lt;com.spiceladdoo.views.RobotTextviewRegular
                                android:layout_width="65dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginTop="5dp"
                                android:gravity="center"
                                android:text="WALLET"
                                android:textColor="@color/offer_name_text_color"
                                android:textSize="12sp" /&gt;

                        &lt;/LinearLayout&gt;

                        &lt;View
                            android:layout_width="5dp"
                            android:layout_height="20dp"

                            android:background="@color/white" /&gt;

                        &lt;LinearLayout
                            android:id="@+id/prepaid_layout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="vertical"&gt;

                            &lt;ImageView
                                android:id="@+id/prepaid_recharge"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/prepaid_recherge" /&gt;

                            &lt;com.spiceladdoo.views.RobotTextviewRegular
                                android:layout_width="65dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginTop="5dp"
                                android:gravity="center"
                                android:text="PREPAID"
                                android:textColor="@color/offer_name_text_color"
                                android:textSize="12sp" /&gt;


                        &lt;/LinearLayout&gt;

                        &lt;View
                            android:layout_width="5dp"
                            android:layout_height="20dp"

                            android:background="@color/white" /&gt;

                        &lt;LinearLayout
                            android:id="@+id/postpaid_layout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="vertical"&gt;

                            &lt;ImageView
                                android:id="@+id/postpaid_recharge"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/postpaid_recherge" /&gt;

                            &lt;com.spiceladdoo.views.RobotTextviewRegular
                                android:layout_width="65dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginTop="5dp"
                                android:gravity="center"
                                android:text="POSTPAID"
                                android:textColor="@color/offer_name_text_color"
                                android:textSize="12sp" /&gt;


                        &lt;/LinearLayout&gt;

                        &lt;View
                            android:layout_width="5dp"
                            android:layout_height="20dp"
                            android:background="@color/white" /&gt;

                        &lt;LinearLayout
                            android:id="@+id/dth_layout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="vertical"&gt;

                            &lt;ImageView
                                android:id="@+id/dth_recharge"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/dth_recherge" /&gt;

                            &lt;com.spiceladdoo.views.RobotTextviewRegular
                                android:layout_width="65dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginTop="5dp"
                                android:gravity="center"
                                android:text="DTH"
                                android:textColor="@color/offer_name_text_color"
                                android:textSize="12sp" /&gt;


                        &lt;/LinearLayout&gt;

                        &lt;View
                            android:layout_width="5dp"
                            android:layout_height="20dp"
                            android:background="@color/white" /&gt;

                        &lt;LinearLayout
                            android:id="@+id/landline_layout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="vertical"&gt;

                            &lt;ImageView
                                android:id="@+id/landline_recharge"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/landline_recherge" /&gt;

                            &lt;com.spiceladdoo.views.RobotTextviewRegular
                                android:layout_width="65dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginTop="5dp"
                                android:gravity="center"
                                android:text="LANDLINE"
                                android:textColor="@color/offer_name_text_color"
                                android:textSize="12sp" /&gt;


                        &lt;/LinearLayout&gt;

                        &lt;View
                            android:layout_width="5dp"
                            android:layout_height="20dp"
                            android:background="@color/white" /&gt;

                        &lt;LinearLayout
                            android:id="@+id/datacard_layout"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:gravity="center"
                            android:orientation="vertical"&gt;

                            &lt;ImageView
                                android:id="@+id/datacard_recharge"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:background="@drawable/datacard_recherge" /&gt;

                            &lt;com.spiceladdoo.views.RobotTextviewRegular
                                android:layout_width="65dp"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:layout_marginTop="5dp"
                                android:gravity="center"
                                android:text="DATACARD"
                                android:textColor="@color/offer_name_text_color"
                                android:textSize="12sp" /&gt;
                        &lt;/LinearLayout&gt;
                    &lt;/LinearLayout&gt;
                &lt;/HorizontalScrollView&gt;
            &lt;/RelativeLayout&gt;

            &lt;LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                android:paddingBottom="10dp"
                android:paddingLeft="5dp"
                android:paddingRight="5dp"
                android:paddingTop="10dp"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center" /&gt;

                &lt;com.spiceladdoo.views.RobotTextviewRegular
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
                    android:layout_marginLeft="10dp"
                    android:text="RECENT"
                    android:textColor="@color/offer_name_text_color" /&gt;

            &lt;/LinearLayout&gt;


            &lt;FrameLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"&gt;

                &lt;LinearLayout
                    android:id="@+id/lincontainer_rec"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:animateLayoutChanges="true"
                    android:divider="?android:dividerHorizontal"
                    android:orientation="vertical"
                    android:paddingLeft="16dp"
                    android:paddingRight="16dp"
                    android:showDividers="middle" /&gt;
            &lt;/FrameLayout&gt;
        &lt;/LinearLayout&gt;
    &lt;/RelativeLayout&gt;
&lt;/android.support.v4.widget.NestedScrollView&gt;
</code></pre>

<p>I am sharing a video click of this problem:</p>

<p><a href="https://www.dropbox.com/s/9yojeq2yw1eebps/layout_height_issue.mp4?dl=0" rel="nofollow">https://www.dropbox.com/s/9yojeq2yw1eebps/layout_height_issue.mp4?dl=0</a></p>

<p>I am banging my head on this from last three days.</p>

<p>Any help will be appreciated.</p>