Situation
I'm writing a pretty simple app using Kotlin
& Android Jetpack Compose
I have a scaffold
containing my navHost
and a bottomBar
.
I can use that bottomBar
to navigate between three main screens.
One of those main screens has a detail screen, which should not show a bottomBar
.
My Code
So far, this was a piece of cake:
// MainActivitys onCreate
setContent {
val navController = rememberAnimatedNavController()
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route?.substringBeforeLast("/")
BottomBarNavTestTheme {
Scaffold(
bottomBar = {
if (currentRoute?.substringBeforeLast("/") == Screen.Detail.route) {
MyBottomNavigation(
navController,
currentRoute,
listOf(Screen.Dashboard, Screen.Map, Screen.Events) // main screens
)
}
}
) { innerPadding ->
NavHost( // to be replaced by AnimatedNavHost
navController = navController,
startDestination = Screen.Dashboard.route,
modifier = Modifier.padding(innerPadding)
) {
composable(Screen.Dashboard.route) { DashboardScreen() }
composable(Screen.Map.route) { MapScreen { navController.navigate(Screen.Detail.route) } }
composable(Screen.Events.route) { EventsScreen() }
composable(Screen.Detail.route) { MapDetailScreen() }
}
}
}
}
Problem:
I would like transitions between my screens, so i'm using Accompanists Navigation Animation:
Just replace NavHost
with AnimatedNavHost
.
When navigating from mainScreen
to detailScreen
there is a strange effect:
- the bottomBar hides
- the main screen resizes: (see the bottom aligned text)
- the animation to the detail screen takes place.
This looks bad, how can i fix it?

Solution
An optimal solution would look like this:
- Main screen keeps bottom bar & fades out.
- Simultaneously the detail page enters without a bottom bar.
Update
I have moved on from this project. For me, this question is no longer relevant and I will likely never be able to accept an answer. However, there seem to be a lot of people interested so i'll just leave this open.