material-components / material-components/material-components-android
[CoordinatorLayout] HeaderScrollingViewBehavior measure child spec overflow
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:** When CoordinatorLayout's height is very small, for example `86dp`, and `headerHeight` in [link](https://github.com/material-components/material-components-android/blob/4c7be527751f1cb11f7c5f55ca5eecbb41c1620c/lib/java/com/google/android/material/appbar/HeaderScrollingViewBehavior.java#L85) is larger than CoordinatorLayout's height(like `90dp`), it will make `height` in [link](https://github.com/material-components/material-components-android/blob/4c7be527751f1cb11f7c5f55ca5eecbb41c1620c/lib/java/com/google/android/material/appbar/HeaderScrollingViewBehavior.java#L89) a negative value(90dp - 86dp = -4dp). `heightMeasureSpec` in [link](https://github.com/material-components/material-components-android/blob/4c7be527751f1cb11f7c5f55ca5eecbb41c1620c/lib/java/com/google/android/material/appbar/HeaderScrollingViewBehavior.java#L91) will be overflow and make second child in CoordinatorLayout measure incorrectly.
If seond child view is a RecyclerView or ListView with many item in it, it will make RecyclerView onMeasure spends lots of time. Because measureSpec overflow will provide a huge height measure size, and make RecylerView layout all item in it's adapter.
**Expected behavior:** `height` should not be negative, or `heightMeasureSpec` 's size should not be overflow
**Source code:** https://github.com/material-components/material-components-android/blob/master/lib/java/com/google/android/material/appbar/HeaderScrollingViewBehavior.java#L89
**Android API version:** Android 11
**Material Library version:** 1.5.0
**Device:** Xiaomi Civi
To help us triage faster, please check to make sure you are using the [latest version](https://github.com/material-components/material-components-android/releases) of the library.
We also happily accept [pull requests](https://github.com/material-components/material-components-android/pulls).
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.
Research direction
Start in lib/java/com/google/android/material/appbar/HeaderScrollingViewBehavior.java around the linked measurement code. Reproduce the issue with a small CoordinatorLayout whose height is smaller than its header, using a RecyclerView or ListView as the second child. Done means the child measurement does not overflow when the header is taller than the CoordinatorLayout and the list no longer receives an unexpectedly huge measure size.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100