BottomNavigationView missing pearls

Android support 25.0.0 new BottomNavigationView outguns all other libraries on the streets. In my previous post on BottomNavigation Behavior, I have explained how should this view benefit and follow the guidelines.

I’ve made quick excursion through the source of BottomNavigationView and I could help but notice that this view does not follow the guidelines on these points:

  • BottomNavigationPresenter does not have stated guideline elevation of 8dp, out of the box.
  • BottomNavigationView group does not have stated default scrolling behavior
  • BottomNavigationView does not guidelines regarding interaction with Snackbar, where bottom navigation component has to be above (8dp) snackbar (6dp).

Fix it, even if it is not broken

Please head to Bottom Navigation Behavior post for more explanation how this works.

In general, there are slightly few changes made in the code that was shown in the previous blog post:

  • Elevation is set to the BottomNavigationView as soon as it is laid out.
  • Works fine in most of cases with Snackbar.

Usage

There are pretty plenty samples on how to use BottomNavigationView. After the release of CoordinatorLayout behavior we have learned that view must be inside CoordinatorLayout in order to consume nested scroll events:

b.android.com

This has been reported as bug here.

Nit-pick

Extend BottomNavigationView and use @DefaultBehavior(BottomNavigationBehavior.class) annotation to set this default behavior.

Bonus

Small enhancement until defects and features are release by support lib team, that exposes public method to set and get items programatically and saving selected position.

Thanks for Joe Birch post & sample project, I was too lazy to write my own.