material-components / material-components/material-components-android
[CollapsingToolbarLayout] Consuming system window insets blocks sibling views from receiving insets
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
CollapsingToolbarLayout is listening to window insets and inside the listener calls:
```java
// Consume the insets. This is done so that child views with fitSystemWindows=true do not
// get the default padding functionality from View
return insets.consumeSystemWindowInsets();
```
While consuming the insets, so its children do not receive them makes sense, due to how insets are dispatched by system, this causes insets to not be dispatched also to its sibling views.
Maybe it could only consume the insets only if `android:fitsSystemWindows="true"`?
After quite some trial & error I discovered a workaround: if I set my own insets listener (doing nothing) on the CollapsingToolbarLayout, I can avoid it consuming the insets. But this feels like hacking around it instead of proper solution.
**Expected behavior:**
System window insets are also dispatched to its sibling views.
**Source code:**
```xml
```
```kotlin
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
ViewCompat.setOnApplyWindowInsetsListener(recyclerView) { _, insets ->
// this will not be called
insets
}
ViewCompat.setOnApplyWindowInsetsListener(appBar) { _, insets ->
// this is called ok
insets
}
}
```
**Android API version:**
I checked on api 29.
**Material Library version:**
1.1.0, 1.2.0-alpha06
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 at CollapsingToolbarLayout's window-insets listener and reproduce the provided CoordinatorLayout with the RecyclerView sibling on API 29. Check that consuming insets for CollapsingToolbarLayout no longer prevents the sibling from receiving them, and add or update coverage if the project provides a relevant test entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100