question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BottomNavigationView] shouldn't calculate bottom system insets when keyboard popup in adjustResize

See original GitHub issue

In 1.1.0-alpha09:

Update BottomNavigation to respect bottom system insets (https://github.com/material-components/material-components-android/commit/276bec8385ec877548fc84994c0a016de2428567)

I found that in adjustResize mode, BottomNavigationView will be pushed up aligned with keyboard popped up, and insets.getSystemWindowInsetBottom() will be keyboard hight, causing BottomNavigationView increase padding bottom to double keyboard hight from screen bottom.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

6reactions
chrisbanescommented, Aug 6, 2019

Just checked the sample from @b95505017 above. The reason this is happening is because of the following layout (my comments inline).

<!-- The CoordinatorLayout is set to fitsSystemWindows  -->
<androidx.coordinatorlayout.widget.CoordinatorLayout
    android:fitsSystemWindows="true">

    <!-- The direct child of the CoordinatorLayout is NOT set to
         fitsSystemWindows, this means that CoL will automatically
         move this view up to match the insets. This is the first
         application of the insets. -->
    <androidx.constraintlayout.widget.ConstraintLayout>

        <!-- The descendent BottomNavigationView is passed the same insets,
             and pads itself. This is the second application. -->
        <com.google.android.material.bottomnavigation.BottomNavigationView />

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>

So how do you fix it? Two options:

  1. Move the BottomNavigationView up to be a child of the CoordinatorLayout, and set it to fitsSystemWindows="true"
  2. Set the ConstraintLayout to fitsSystemWindows="true" AND set an OnApplyWindowInsetsListener on it to ignore the inset (so that only the BottomNavigation handles it). Slide 143 from this talk goes through a similar example.
3reactions
b95505017commented, Aug 3, 2019

@wcshi Here is the sample of adjustResize

My workaround is extend BottomNavigationView and remove insets listener:

class BottomNavigationViewFix: BottomNavigationView {
    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    init {
        setOnApplyWindowInsetsListener(null)
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to hide the BottomNavigationView below keyboard with ...
The idea is that when keyboard is shown, system insets are changed with pretty big .bottom value. Share.
Read more >
BottomNavigation behavior with an on-screen keyboard on ...
Implementing UX-flows with bottom navigation and on-screen keyboards on Android should be easy. But like most of you already know, it isn't.
Read more >
How To Hide The Bottomnavigationview Below ... - ADocLib
shouldn't calculate bottom system insets when keyboard popup in adjustResize. In 1.1.0alpha09: Update BottomNavigation to respect bottom system insets.
Read more >
android jetpack data binding - Tumblr
The expression parser automatically tries to find the Java Bean accessor name (getXxx() or isXxx()) for your property. The same expression will work...
Read more >
Layout suppressed after keyboard shown with ... - Issue Tracker
When BottomNavigationView is used with ConstraintLayout 2.0.0-beta02, there is some weird behavior after showing the keyboard with adjustResize input mode.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found