I need to navigate a stack of fragments and I am navigating back using the toolbar back button. Can I override the back button pressed to set a custom animation, for example slide out?
Here is the code for the toolbar.
private fun setupToolbar() {
val appBarConfiguration = AppBarConfiguration(navController.graph, drawer_layout)
val toolbar = toolbar as Toolbar
setSupportActionBar(toolbar)
toolbar.setupWithNavController(navController, appBarConfiguration)
val ab: ActionBar? = supportActionBar
ab?.setDisplayShowTitleEnabled(false) // disable the default title element here (for centered title)
setupSearchQueryListener()
}