I was trying out Android Navigation Architecture Component and was also looking into Material design guidelines. I really got inspired by the design below:
Just use onCreateOptionsMenu()
for the Toolbar
as usual: (Kotlin)
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
menuInflater.inflate(R.menu.menu_first, menu)
return super.onCreateOptionsMenu(menu)
}
Then declare the Toolbar
inside onCreate()
and use setSupportActionBar()
:
val toolbar = findViewById(R.id.myToolbar)
setSupportActionBar(toolbar)
And after that, replaceMenu()
will do the trick: (Inside onCreate()
)
val bottomBar = findViewById(R.id.bottomAppBar)
bottomBar.replaceMenu(R.menu.menu_main)
Note that if you wanted to use BottomSheetFragment
for the NavigationView
opening, you'll need setSupportActionBar
in order to set menu
s for the BottomAppBar
and I couldn't still find a way to fix this.