[AppBarLayout] "scroll" layout flag problematic on Android 17 QPR1 and QPR2 (autoscrolls when it should not)
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
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from material-components/material-components-android
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug Widget: Chip
Difficulty 1/5 Under an hour Newbie friendliness 72/100
material-components/material-components-android#5070 · 1 comment ·
-
bug Widget: TimePicker
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in material-components/material-components-android
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100