[AppBarLayout] "scroll" layout flag problematic on Android 17 QPR1 and QPR2 (autoscrolls when it should not)

Open
#5,100 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, java
Domain
mobile-dev

Research direction

Start by reproducing the issue with a MaterialToolBar child of AppBarLayout using app:layout_scrollFlags="scroll", BottomNavigationView, fragments in ViewPager2, and setCurrentItem on Android 17 QPR1/QPR2 or API 37.1/37.2. Compare tab switching with regular Android 17 and below, and verify that switching tabs no longer auto-scrolls the toolbar while normal content scrolling still hides it.

Written by the indexing model from the issue text.

Description

bug

Observed on v1.14.0 on a Google Pixel Pro running QPR2 Beta 4. Also happens in the emulator running Android 17 API 37.1 and 37.2

See this issue report on the Android beta tracker (post 7) for more details and a video showing the issue in my app.

The problem is that a MaterialToolBar child of an AppBarLayout with app:layout_scrollFlags="scroll" (possibly combined with other flags but only scroll is important), always auto-scrolls when a BottomNavigationView (see video) that uses fragments within a ViewPager2 for its tabs, switches tabs (ViewPager#setCurrentItem).
It results in unwanted scrolling of the MaterialToolBar when switching tabs This issue does not happen on regular Android 17 and below. It started to happen in an early Android 17 QPR beta version a few months ago.

It is hugely annoying and the only work-around I found for now is to disable "scroll" on the MaterialToolBar if the app is running on Android 17 QPR:

if(Misc.isAndroid17_1_OrLater()) {
            ((AppBarLayout.LayoutParams) _toolbar.getLayoutParams()).setScrollFlags(0);
        }

Normally, the MaterialToolBar scrolls up (hides) when use scrolls the content, but this workaround disable it.

Mind you, the YouTube app is also affected (the issue report linked above was initially for the YT app).

Would be awesome if it could be looked into.

Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from material-components/material-components-android

All issues in material-components/material-components-android

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.