If Toolbar property "extendBackground" is set true and the top status bar is transparent and the bottom navigation bar is transparent, then the Toolbar will end up being taller than expected. The Toolbar's top padding will be set to the status bar's height and the Toolbar's bottom padding will be set to the navigation bar's height.
Steps to reproduce:
- Build and run the below code on Android 4.4 or higher.
- Notice the Toolbar has too much bottom padding.
In this case, the Toolbar's bottom padding is not desired. It's expected to look like attached screenshot "NavBarOpaque.png", where if the bottom navigation bar is opaque, no bottom padding is added to the Toolbar.
- This is likely an issue on Google's end since they handling the padding internally.
- This is a low priority issue since most apps (such as Google's apps) don't make both top and bottom system bars transparent at the same time.
- Work-around is to not make the bottom navigation bar translucent... or leave the "extendBackground" property false and color the status bar via a theme.
- Ideally, we would also want to support displaying a Toolbar at the bottom of the screen too. In which case, "extendBackground" should extend down beneath a transparent navigation bar. (Would we need a new property indicating which direction we want to extend towards?)
Override the Java Toolbar class' fitSystemWindows(Rect) method and strip-off the top or bottom inset before passing the rect over to super.fitSystemWindows(Rect). This will work because Google's base View implementation blindly adds the insets as padding to the view.