You need add in your code :
recyclerView.setNestedScrollingEnabled(false)
app:layout_behavior should be added to the direct child of CoordinatorLayout. and after you need to use NestedScrollView in SwipeLayout like;
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
...
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
app:layout_behavior
should be added to the direct child of CoordinatorLayout
.
So you should move app:layout_behavior="@string/appbar_scrolling_view_behavior"
from NestedScrollView
to SwipeRefreshLayout
.
<android.support.design.widget.CoordinatorLayout ...>
<android.support.design.widget.AppBarLayout ...>
...
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
...
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.CoordinatorLayout>
I solved it by myself to put the SwipeRefreshLayout as the main layout and add the rest as children
use this
<android.support.v4.widget.SwipeRefreshLayout 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:id="@+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
... your attribute here ... >
<android.support.design.widget.AppBarLayout
... your attribute here ... >
<android.support.design.widget.CollapsingToolbarLayout
... your attribute here ... >
... your element here ...
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
... your attribute here ... >
... your element here ...
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>