Material-components-android: [BottomNavigationView] Adding extra padding

Created on 5 Aug 2019  路  22Comments  路  Source: material-components/material-components-android

Description: Whenever full-screen mode enabled by code icons are shrinking and after debugging I got to know that it's adding extra padding at the bottom.

Expected behavior:

Screen Shot 2019-08-05 at 9 39 45 AM

photo_2019-08-05 09 32 42

Source code:

val flags = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_FULLSCREEN
                or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)

        if (PreferenceUtil.getInstance().fullScreenMode) {
            window.decorView.systemUiVisibility = flags
        }

Android API version: Android 28

Material Library version: 1.1.0-alpha09

Device: Xioami Pocco f1

To help us triage faster, please check to make sure you are using the latest version of the library.

We also happily accept pull requests.

bug

Most helpful comment

@h4h13 subclass BottomNavigationView and within the init block add the following line setOnApplyWindowInsetsListener(null) (You may need to setPadding(0) too)

All 22 comments

I am unable to reproduce the bug in the catalog app using the flags you provided, could you please share a sample app?

@h4h13 are you setting a fixed height on the BottomNavigationView?

@wcshi why you ask about the fixed height?
I have somehow a similar issue #431 where I'm using 56dp as a bnb with different values for every swXXXdp I can come up with.
Since you asked about the height I'm curious if that is something that is affecting me too.

BottomNavigationView should have layout_height set to wrap_content in order to handle the extra padding adjustment from edge to edge w/o its contents getting squished.

@wcshi Yes I have fixed height too for 56dp should remove fixed height works?

@h4h13 I have removed fixed height but when I enable full screen this happens
photo_2019-08-06 19 14 41

By layout inspector I got it 132
Screen Shot 2019-08-06 at 7 18 32 PM

@h4h13 that is what I expect, the BottomNavigationView is offset by the height of the navigation bar (132). What is your desired behavior?

@wcshi Should be no padding at bottom

@h4h13 what system ui flags are you setting?

val flags = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                or View.SYSTEM_UI_FLAG_FULLSCREEN
                or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY)

        if (PreferenceUtil.getInstance().fullScreenMode) {
            window.decorView.systemUiVisibility = flags
        }

@h4h13 subclass BottomNavigationView and within the init block add the following line setOnApplyWindowInsetsListener(null) (You may need to setPadding(0) too)

@paolovalerdi @h4h13 please do not subclass bottomNavigationView just to do that. Have you read this comment? It may apply to your situation as well.

I used the same flags in the catalog app and did not observe the extra paddings. Could you please share a sample app to reproduces your bug?

@paolovalerdi as I mentioned in this comment please file a separate bug with a sample app for your bug, thank you.

@paolovalerdi It did help my problem of doing this!.

@wcshi I have subclass for theme thing bnb

@h4h13 why did you subclass BottomNavigationView? To workaround the extra padding or something else?

If you just want to setOnApplyWindowInsetsListener(null), you can do set it in your app instead.
https://speakerdeck.com/chrisbanes/becoming-a-master-window-fitter-droidcon-london-2017?slide=158

Closing due to inactivity. Please reopen with additional info.

Here's a sample app.

Entering immersive mode with following flags:

window.decorView.systemUiVisibility = (
                View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                        or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                        or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                        or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        or View.SYSTEM_UI_FLAG_FULLSCREEN
                )

Running on 1.1.0-alpha09 and above with API 28 simulator has extra padding:
Screenshot_1573523528

I expect no padding as running on 1.1.0-alpha08 so we can use BottomNavigationView with immersive mode:
Screenshot_1573523435

@wcshi please take a look if you have time, thanks!

Can we get paddingBottomSystemWindowInsets as with BottomAppBar? I would like to remove the padding and use margin instead, because I would like the text to be visible under the transparent navigation bar. The padding used makes that area opaque.

@TadejZupancic Yep. We're working on adding the same support for paddingBottomSystemWindowInsets to BottomNavigationView.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Sanusy picture Sanusy  路  3Comments

JakeWharton picture JakeWharton  路  3Comments

magnusfernandes picture magnusfernandes  路  3Comments

JavierSegoviaCordoba picture JavierSegoviaCordoba  路  3Comments

TdevM picture TdevM  路  3Comments