I have search all questions here related to my question but none helped so far. What I am trying to achieve is to have the middle toolbar collapse when the the fragment in the ViewPager is scrolled down and the TabLayout will just pin. Here's the structure of my main layout file. Nothing happens when I scroll down.
Please help me. Any help would be greatly appreciated
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" >
</android.support.v7.widget.Toolbar>
<android.support.design.widget.CollapsingToolbarLayout
android:layout_height="72dp"
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:background="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:popupTheme="@style/AppTheme.PopupOverlay">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax">
<RelativeLayout android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_gravity="top"
android:paddingRight="20dp"
android:paddingLeft="20dp"
android:layout_height="wrap_content">
<TextView android:id="@+id/tv_song_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:layout_alignParentLeft="true"
android:textSize="20sp"
android:ellipsize="marquee"
android:singleLine="true"
android:text="Bloody Stream"/>
<TextView android:id="@+id/tv_artist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/tv_song_name"
android:textSize="15sp"
android:fontFamily="Sans-serif-light"
android:textColor="#9E9E9E"
android:text="by Coda"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:layout_below="@+id/tool_bar"
android:layout_gravity="center_horizontal"
android:layout_alignParentStart="true"
android:fitsSystemWindows="true"
app:tabGravity="fill"
app:tabMode="fixed"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
android:src="@drawable/ic_file_download_white_24dp" />