Lucien Guimaraes
02/25/2021, 12:32 PMLucien Guimaraes
02/25/2021, 12:32 PMval scrollState = rememberScrollState()
BoxWithConstraints {
val partScreen = 3 //screen divider, as the header is an image taking a third of the screen
val offset = (scrollState.value / partScreen)
val offsetDp = with(LocalDensity.current) { offset.toDp() }
val maxHeight = this@BoxWithConstraints.maxHeight / partScreen
val tobAppBarBackgroundColorAlpha: Float by animateFloatAsState(
when (scrollState.value) {
0f -> {
0f
}
in 0f..maxHeight.value -> {
scrollState.value/maxHeight.value
}
else -> {
1f
}
}
)
Column(modifier = Modifier
.fillMaxSize()
.verticalScroll(scrollState)) {
CoilImage(
modifier = Modifier
.preferredHeightIn(max = maxHeight)
.fillMaxWidth()
.padding(top = offsetDp),
data = hikeDetail.picture,
contentScale = ContentScale.Crop,
contentDescription = null
)
... // content of screen
}
TopAppBar(
modifier = Modifier
.fillMaxWidth()
.statusBarsPadding(),
title = {},
backgroundColor = Color.White.copy(alpha = tobAppBarBackgroundColorAlpha),
elevation = 0.dp,
contentColor = MaterialTheme.colors.onSurface,
navigationIcon = {
IconButton(
modifier = Modifier.background(
color = MaterialTheme.colors.surface,
shape = CircleShape
),
onClick = { onBackPressed() },
) {
Icon(
painter = painterResource(id = R.drawable.ic_back),
contentDescription = null,
tint = MaterialTheme.colors.onSurface,
)
}
}
)
}
Lucien Guimaraes
02/25/2021, 12:32 PMTimo Drick
02/25/2021, 12:50 PMLucien Guimaraes
02/25/2021, 12:52 PMLucien Guimaraes
02/25/2021, 12:52 PMTimo Drick
02/25/2021, 12:54 PMLucien Guimaraes
02/25/2021, 1:24 PMisScrollInProress
do you mean isAnimationRunning instead ?Timo Drick
02/25/2021, 1:25 PMTimo Drick
02/25/2021, 1:26 PMLucien Guimaraes
02/25/2021, 1:27 PMLucien Guimaraes
02/25/2021, 1:29 PMisScrollInProress/isAnimationRunning
is a boolean, it doesn't get the scroll value. So I'm not sure to followLucien Guimaraes
02/25/2021, 1:30 PMTimo Drick
02/25/2021, 1:30 PMLucien Guimaraes
02/25/2021, 1:31 PMTimo Drick
02/25/2021, 1:33 PMTimo Drick
02/25/2021, 1:37 PMLucien Guimaraes
02/25/2021, 1:39 PMTimo Drick
02/25/2021, 1:42 PMLucien Guimaraes
02/25/2021, 1:42 PMOh i see. I think there is a nestedScroll modifier maybe this would help.Ok I will check 🙂
Klaas Kabini
02/25/2021, 6:17 PMLucien Guimaraes
02/25/2021, 6:55 PMKlaas Kabini
02/25/2021, 7:03 PMLucien Guimaraes
02/25/2021, 7:12 PMLucien Guimaraes
02/25/2021, 7:12 PMGeert
03/26/2021, 5:54 PMLucien Guimaraes
03/27/2021, 6:40 PM