The goal is to have a collapsing toolbar
and a SwipeRefreshLayout
which has items. To be able to use the support library, I use CoordinatorLayout
which hosts an AppBarLayout
. That AppBarLayout
has a toolbar
and SwipeRefreshLayout
which has a grid view. Using app:layout_scrollFlags="scroll|enterAlways"
there is no problem with collapsing and opening the toolbar
, however SwipeRefreshLayout
does not swipe all the way down, i.e., it is stuck. When taking the SwipeRefreshLayout
out of AppBarLayout
, it scrolls fine but this time the toolbar does not collapse. below is the layout xml. any help is appreciated.
PS: I used this link for collapsing toolbar implementation:
Here's my layout:
<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_height="match_parent"
android:layout_width="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="50dp"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="@color/primary_dark"
app:layout_scrollFlags="scroll|enterAlways">
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swiperefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<GridView
android:id="@+id/gridview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:stretchMode="columnWidth"
android:numColumns="2"/>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.design.widget.AppBarLayout>
</android.support.design.widget.CoordinatorLayout>