解决CollapsingToolbarLayout和ViewPager滚动矛盾

参考文档:https://gist.github.com/iPaulPro/1468510f046cb10c51ea

项目用用到了CollapsingToolbarLayout和ViewPager,ViewPager中又包含一个ListView, 类似上图中效果,但是做完的效果是ListView不能推动CollapsingToolbarLayout滚动,困扰了我好久,解决方案请参考上述链接,我贴出我解决问题用的布局

<?xml version="1.0" encoding="utf-8"?>  
<android.support.design.widget.CoordinatorLayout 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="match_parent" android:fitsSystemWindows="true">  
  <android.support.v4.view.ViewPager android:id="@+id/viewpager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="40dp" android:layout_weight="1" android:background="@android:color/white" app:layout_behavior="@string/appbar_scrolling_view_behavior"/>  
  <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:orientation="vertical" app:layout_anchor="@+id/appbar" app:layout_anchorGravity="bottom"> 
    <android.support.design.widget.TabLayout android:id="@+id/sliding_tabs" android:layout_width="match_parent" android:layout_height="40dp" android:textAllCaps="false" app:tabGravity="fill" app:tabIndicatorColor="#39AFF7" app:tabSelectedTextColor="#39AFF7"/>  
    <View android:layout_width="match_parent" android:layout_height="0.5dp" android:background="#39AFF7"/> 
  </LinearLayout>  
  <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> 
    <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginStart="16dp" app:layout_scrollFlags="scroll|exitUntilCollapsed" app:statusBarScrim="?attr/colorPrimary"> 
      <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/backdrop" android:layout_width="match_parent" android:layout_height="300dp" android:scaleType="fitStart" android:transitionName="mu" app:actualImageScaleType="focusCrop" app:layout_collapseMode="parallax" app:layout_collapseParallaxMultiplier="0.7"/>  
      <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:popupTheme="@style/ThemeOverlay.AppCompat.Light" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" app:layout_collapseMode="pin"/> 
    </android.support.design.widget.CollapsingToolbarLayout> 
  </android.support.design.widget.AppBarLayout> 
</android.support.design.widget.CoordinatorLayout>

用到LinearLayout仅仅是为了增加一个分割线

我的效果图