material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[BottomNavigationView] Adding extra padding

Open h4h13 opened this issue 7 years ago • 22 comments

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.

h4h13 avatar Aug 05 '19 04:08 h4h13

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

wcshi avatar Aug 05 '19 15:08 wcshi

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

wcshi avatar Aug 05 '19 20:08 wcshi

@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.

GuanacoDevs avatar Aug 06 '19 02:08 GuanacoDevs

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 avatar Aug 06 '19 13:08 wcshi

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

h4h13 avatar Aug 06 '19 13:08 h4h13

@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 avatar Aug 06 '19 13:08 h4h13

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

wcshi avatar Aug 06 '19 14:08 wcshi

@wcshi Should be no padding at bottom

h4h13 avatar Aug 06 '19 16:08 h4h13

@h4h13 what system ui flags are you setting?

wcshi avatar Aug 06 '19 17:08 wcshi

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 avatar Aug 06 '19 17:08 h4h13

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

paolovalerdi avatar Aug 08 '19 17:08 paolovalerdi

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

wcshi avatar Aug 08 '19 18:08 wcshi

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?

wcshi avatar Aug 08 '19 18:08 wcshi

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

wcshi avatar Aug 08 '19 18:08 wcshi

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

@wcshi I have subclass for theme thing bnb

h4h13 avatar Aug 08 '19 19:08 h4h13

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

wcshi avatar Aug 08 '19 20:08 wcshi

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

wcshi avatar Aug 08 '19 21:08 wcshi

Closing due to inactivity. Please reopen with additional info.

wcshi avatar Aug 18 '19 20:08 wcshi

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

IvanBean avatar Nov 12 '19 02:11 IvanBean

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

IvanBean avatar Nov 19 '19 15:11 IvanBean