material-components / material-components/material-components-android

[ViewPager2] WindowInsetsApplier break insets with BottomNavigationView below API 30

Open
#3,459 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**Description:** WindowInsetsApplier break insets with BottomNavigationView below API 30.

**Expected behavior:** WindowInsetsApplier will not break insets with BottomNavigationView.

**Source code:**
on activity :
```
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
WindowCompat.setDecorFitsSystemWindows(window,false)
// fix the broken `WindowInsets` dispatch of old API versions (< 30)
WindowInsetsApplier.install(binding.viewpager)
binding.viewpager.isUserInputEnabled = false
bottomNavigationMediator =
BottomNavigationViewMediator(binding.bottomNavView, binding.viewpager)
bottomNavigationMediator.attach()
}
```

on layout:
```

```

Above codes will reproduce the issue below API 30.

Once we switch the order of ViewPager2 and BottomNavigationView in xml, the issue is gone:
```


```

But with version 1.0.0 of ViewPager2 , or not calling `WindowInsetsApplier.install`, no matter order is with ViewPager2 and BottomNavigationView, this issue will not happen.

**Minimal sample app repro:**
[ViewPager2Issue](https://github.com/kolyneh/ViewPager2Issue)

**Android API version:** Android API 28

**Material Library version:** material 1.9.0 and viewpager2 1.1.0-beta02

**Device:** AVD API 28

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.

Research direction

Start with the linked ViewPager2Issue sample app and the WindowInsetsApplier.install(binding.viewpager) call. Reproduce on API 28 with ViewPager2 before BottomNavigationView, then compare the reversed XML order and the behavior without installation. Done means insets remain correct with the original layout order below API 30.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.