Reputation: 1488
When you register a toolbar with navigation architecture it will create an arrow allowing you to pop up on the fragment you are on.
On a few base level fragments I don't want to have the Hamburger menu icon nor the arrow but a custom view object.
How would I disable the back button from view?
I have tried manually disabling but am having a hard time finding out how to manage it with Navigation arch.
val supportActionBar = activity?.actionBar
if (supportActionBar != null) {
supportActionBar.setDisplayShowHomeEnabled(false)
supportActionBar.setDisplayHomeAsUpEnabled(false)
supportActionBar.setHomeButtonEnabled(false)
supportActionBar.setHomeAsUpIndicator(null)
}
Upvotes: 2
Views: 1594
Reputation: 81
I solved this problem with this:
val actionBar = (activity as AppCompatActivity).supportActionBar
actionBar?.setDisplayHomeAsUpEnabled(false)
Anyway, you should also keep in mind that you need to change navigation graph to set proper popUpTo destination or somehow disable system back button.
Upvotes: 0
Reputation: 1488
Well after a good hour I hope that my pain and oversight really helps someone out. After Navigation Architecture forces you to load up a drawable into the navigation icon the only solution I came up with was to nullify it.
toolbar.navigationIcon = null
Upvotes: 2