Android BottomNavigationView evenly spaced icons
Asked Answered
L

3

8

I have a BottomNavigationView with five items. The default behavior is to only show the label of the selected item and the spacing between all five items differs depending on what item is selected.

I would like a bottom bar more simular to a UITabBar on iOS. Is this possible with BottomNavigationView or can you recommend some other library that solves this?

Leghorn answered 30/11, 2016 at 20:47 Comment(4)
You don't want it to somewhat bubble out when it's selected right? Kind of like what's happening here in the MD Design Guidelines, correct? material-design.storage.googleapis.com/publish/material_v_9/…Loisloise
Correct. I want all tabs to be equal size all the time, not matter which one is selected.Leghorn
Yea, seems like this initial release of the BottomNavigationView has come with a lot of limitations. I would recommend converting to a tabLayout if that fits your requirements as it allows you to set a "fixed" size for all the tabs. There is also more info in the link to follow that may be of help, you could extend BottomNavigationView and attempt to disable the bubbling effect yourself. https://mcmap.net/q/160761/-remove-bottomnavigationview-labelsLoisloise
Possible duplicate of How to disable BottomNavigationView shift mode?Salenasalene
H
8

You just need to disable the shift mode: How to disable BottomNavigationView shift mode?

When you have more than 3 tabs, the shift mode is enabled by default. This can only be set to disabled by tricky method using Reflection now.

Hallucinatory answered 27/12, 2016 at 6:41 Comment(0)
T
0

There are loads of libraries out there but you can check this and this out.

Anyway, a screenshot of your UI would've been better to query the default behavior.

Tuberculate answered 30/11, 2016 at 20:57 Comment(0)
L
0

UPDATE

You also need to update proguard configuration file (e.g. proguard-rules.pro), code above uses reflection and won't work if proguard obfuscate the mShiftingMode field.

-keepclassmembers class android.support.design.internal.BottomNavigationMenuView { 
    boolean mShiftingMode; 
}
Ligule answered 31/8, 2017 at 22:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.