i am using top bar that is scrolled along with lazycolumn it works, but when the lazy column scrolled down the topbar collapses but i don’t want to collapse it. And topbar should be fixed height and need to scroll along with lazy column when user scrolled down. Also the top bar should be visible when scrolled up in lazycolumn immediately.
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior( )
TopAppBar(scrollBehavior = scrollBehavior,
title = {
Text(
text = "Home",
color = MaterialTheme.colorScheme.primary,
fontSize = 18.sp
)
},
}
I could see there is possible but i don’t know, how to fix it. the doc says,
/**
* Returns a [TopAppBarScrollBehavior]. A top app bar that is set up with this
* [TopAppBarScrollBehavior] will immediately collapse when the content is pulled up, and will
* immediately appear when the content is pulled down.
*
* @param state the state object to be used to control or observe the top app bar's scroll
* state. See [rememberTopAppBarState] for a state that is remembered across compositions.
* @param canScroll a callback used to determine whether scroll events are to be handled by this
* [EnterAlwaysScrollBehavior]
* @param snapAnimationSpec an optional [AnimationSpec] that defines how the top app bar snaps
* to either fully collapsed or fully extended state when a fling or a drag scrolled it into
* an intermediate position
* @param flingAnimationSpec an optional [DecayAnimationSpec] that defined how to fling the top
* app bar when the user flings the app bar itself, or the content below it
*/
@ExperimentalMaterial3Api
@Composable
fun enterAlwaysScrollBehavior(
state: TopAppBarState = rememberTopAppBarState(),
canScroll: () -> Boolean = { true },
snapAnimationSpec: AnimationSpec<Float>? = spring(stiffness = Spring.StiffnessMediumLow),
flingAnimationSpec: DecayAnimationSpec<Float>? = rememberSplineBasedDecay()
): TopAppBarScrollBehavior =
EnterAlwaysScrollBehavior(
state = state,
snapAnimationSpec = snapAnimationSpec,
flingAnimationSpec = flingAnimationSpec,
canScroll = canScroll
)