question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[AppBarLayout] AppBarLayout does not collapse/expand when scrolling vertically over horizontal RecyclerView inside vertical RecyclerView

See original GitHub issue

Description: When vertical RecyclerView has a horizontal RecyclerView and if user starts scrolling vertically with finger on horizontal RecyclerView then AppBarLayout does not move at all. If finger was on other list items then AppBarLayout does change its state.

The problem is still there with CollapsingToolbarLayout inside AppBarLayout.

ezgif com-video-to-gif

Expected behavior: AppBarLayout should scroll

Source code: I created a test project where you can see the problem. https://github.com/MaratTursynbek/AppBarLayout-bug

Code of CollapsibleToolbar is taken from this article.

<androidx.coordinatorlayout.widget.CoordinatorLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:id="@+id/app_bar_layout"
        android:layout_width="match_parent"
        android:layout_height="76dp"
        android:theme="@style/AppTheme.AppBarOverlay.Light">

        <com.example.notcollapsingappbar.CollapsibleToolbar
            android:id="@+id/motion_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:minHeight="@dimen/actionBarSize"
            app:layoutDescription="@xml/scene_header"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

            <TextView
                android:id="@+id/toolbar_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="start|center_vertical"
                android:text="Large title"
                android:textColor="@android:color/white"
                android:textSize="30sp"
                app:autoSizeTextType="uniform" />

        </com.example.notcollapsingappbar.CollapsibleToolbar>

    </com.google.android.material.appbar.AppBarLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recycler_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingBottom="16dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

</androidx.coordinatorlayout.widget.CoordinatorLayout>

Android API version: All versions from API 21

Material Library version: 1.2.1

Device: OnePlus 5t, Pixel 3, Pixel 3 emulator, Samsung A10

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
PallabJuniorcommented, Jan 28, 2022

I had the same issue and android:nestedScrollingEnabled=“false” does solve it for the nested recyclerviews. But I have a horizontal ViewPager inside a vertical recyclerView which is giving me this same issue and cann’t be resolved by using android:nestedScrollingEnabled =false.

What is the solution for that?

1reaction
araujotadeucommented, Aug 1, 2022

What’s the solution to this issue? I am having the same problem as PallabJunior, not working with a ViewPager2.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AppBarLayout does not collapse/expand when scrolling ...
When vertical RecyclerView has a horizontal RecyclerView and if user starts scrolling vertically with finger on horizontal RecyclerView then  ...
Read more >
Appbarlayout Does Not Collapse/Expand When ... - ADocLib
Appbarlayout Does Not Collapse/Expand When Scrolling Vertically Over Horizontal Recyclerview Inside Vertical. 1 Introduction 2 Creating a Nested ScrollView ...
Read more >
Unable to scroll vertically when touch horizontal recyclerview ...
When I touch the horizontal recyclerview of the item and scroll up/down, I can't scroll vertically (through the outer scrollview).
Read more >
How to Create a Collapsing ToolBar and FAB on Scroll with ...
In this article, we are going to create a collapsing Toolbar and Floating action button (FAB) on scroll with RecyclerView.
Read more >
Handling Scrolls with CoordinatorLayout - CodePath Cliffnotes
Scroll events in the RecyclerView trigger changes inside views declared within AppBarLayout by using the app:layout_scrollFlags attribute:
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found