ListView中嵌套RecyclerView,RecyclerView放图片左右滑动,ListView放在CoordinatorLayout布局,当触碰recyclerView上下滑动时ListView会滑动,但不是CollapsingToolbarLayout先滑动折叠。
这是布局
<?xml version="1.0" encoding="utf-8"?>
android:id="@+id/homepage_head"
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"
android:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:fitsSystemWindows="true"
app:titleEnabled="false"
android:theme="@style/AppTheme.AppBarOverlay"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_marginTop="?attr/actionBarSize"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
…………
</LinearLayout>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay" >
…………
</android.support.v7.widget.Toolbar>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<cn.view.MyListView
<!--item包含RecyclerView -->
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_width="match_parent"
android:dividerHeight="8dp"
android:layout_height="match_parent"></cn.view.MyListView>
</android.support.v4.widget.NestedScrollView>