Navigation drawer and toolbar appears in splash screen

Viewed 309

I am building an app using jetpack navigation with navigation drawer and toolbar, and a splash screen. I set the splash screen fragment to be the entry destination. However when the splash screen starts, the drawer and the toolbar appear on screen. How to remove them from splash screen but keeping them in all other fragment? The drawer layout is set in the main activity and it is the navhost

2 Answers

You have to separate splash activity from others.

Activity 1 -> Splash

Activity 2 -> Navigation Drawer (and all fragments)

Thanks for your answers. I ended up having 2 activities and 2 nav graphs. The first activity handles the splash screen and the login screen, while the second one handles the rest of the app where the nav drawer should exists. However by doing this, I ran into another problem where I couldn't clear the splash screen from the backstack as each navgraph has its own stack. To solve this I called the function finish() in Activity 1 after calling navController.navigate(R.id.Activity 2) to pop activity 1 from the app's main stack.

Related