I'm wanting to present a collapsible bar below a sticky top bar. In the initial state when the collapsible bar is fully expanded, I want both bars to look like they are on the exact same elevation. Then, when the collapsible bar collapses on scroll, the sticky bar should elevate up and the collapsible bar should look as if it's sliding underneath the sticky top bar.
The issue I'm seeing is in the initial state, there's a light dividing shadow between the two bars in dark mode even though they have the exact same elevation value.
Relevant code (left out the scroll logic for brevity):
Column(modifier = Modifier.fillMaxWidth()) {
TopAppBar(
navigationIcon = {
IconButton()
},
title = {
Text(text = "Sticky top app bar")
},
elevation = 4.dp,
)
Surface(
modifier = Modifier.fillMaxWidth(),
elevation = 4.dp,
) {
Text(text = "Collapsible top app bar")
}
}
Anyone familiar with how to avoid that dividing shadow between the two bars?

I ended up adding
material3to my project, updating toandroidx.compose.material3.Surfaces, setting the initialshadowElevationof the sticky top bar to0.dp, and then gradually animatingshadowElevationbased on the collapsing top bar scroll progress.