0

When using the Android navigation framework I have IntroFragment as the root and MainFragment as a destination from IntroFragment. In IntroFragment I call:

view.findNavController().navigate(IntroFragmentDirections.actionIntroFragmentToMainFragment())

The xml for that action is:

<action android:id="@+id/action_introFragment_to_mainFragment" app:destination="@id/mainFragment"
            app:exitAnim="@anim/slide_out_right" app:popUpTo="@+id/main" app:popUpToInclusive="true"/>

Despite the popUpToInclusive, a back arrow still appears in the toolbar in the MainFragment. I haven't been able to find a way to get rid of it. I have confirmed that pressing the back soft-key does exit the activity.

der_Fidelis
  • 1,475
  • 1
  • 11
  • 25

1 Answers1

1

Using app:popUpTo not influencing if the back arrow appears or not, it is only influence what happening when you clicking on back button. To get rid of back arrow on MainFragment you should define it as top-level destination using AppBarConfiguration:

val appBarConfiguration = AppBarConfiguration.Builder(setOf(R.id.main, R.id.mainFragment)).build()
NavigationUI.setupWithNavController(toolbar, navController, appBarConfiguration) 
Alex
  • 9,102
  • 3
  • 31
  • 35