firetrap
firetrap

Reputation: 2015

Android CollapsingToolbarLayout cant collapse when recyclerView it's not visible

I've a CoordinatorLayout with AppBarLayout and CollapsingToolbarLayout everything works at it should when in portrait mode because my recyclerView it's visible and i can collpase the toolbar by dragging the recyclerView, but when the recyclerView it's not visible i cant collpase the toolbar.

my xml:

 <android.support.design.widget.CoordinatorLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsing_toolbar"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:collapsedTitleTextAppearance="@android:color/transparent"
            app:expandedTitleTextAppearance="@android:color/transparent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <ImageView
                android:id="@+id/backdrop"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:fitsSystemWindows="true"
                android:scaleType="centerCrop"
                android:src="@drawable/image_adega"
                app:layout_collapseMode="parallax"/>

        </android.support.design.widget.CollapsingToolbarLayout>

        <include
            android:id="@+id/list_wines_toolbar"
            layout="@layout/toolbar"/>

        <android.support.design.widget.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>

    </android.support.design.widget.AppBarLayout>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recycler_view_wines"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="vertical"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

</android.support.design.widget.CoordinatorLayout>

Portrait - RecyclerView visible - can drag can collapse can collapse

Landscape - RecyclerView not visible - can't drag can't collapse can't collapse

PS: I've updated to all support and design libs to 23.0.1 and it's the same result

Upvotes: 0

Views: 1260

Answers (3)

yoAlex5
yoAlex5

Reputation: 34331

You can use Android Support Library 23.1

You’ll also find that AppBarLayout now allows users to start scrolling from within the AppBarLayout rather than only from within your scrollable view - this behavior can be controlled by adding a DragCallback

Upvotes: 2

firetrap
firetrap

Reputation: 2015

After some digging and try and error i found this is know bug still present in 23 versions. code google

Upvotes: 1

Bhavesh Patadiya
Bhavesh Patadiya

Reputation: 25830

I've a CoordinatorLayout with AppBarLayout and CollapsingToolbarLayout everything works at it should when in portrait mode because my recyclerView it's visible and i can collpase the toolbar by dragging the recyclerView, but when the recyclerView it's not visible i cant collpase the toolbar. Blockquote

In Landscape mode, you are not able to collapse the toolbar because you are not having any scrollable content in your view such like RecyclerView.

This also should be the expected behavior. Regarding your concern about landscape mode, I would recommend you to re-think about landscape mode design and make it such that your AppBar contains 60-70% height of your device and rest of them should contain your Scrollable view. you can take Playstore app for your reference.

I hope it helps.

Upvotes: 1

Related Questions