I have an Image
as a background. I want that after scrolling up to 1.5x the height of the screen, the alpha value of the Composable start changing. his is the logic that seems correct to me:
val contentOffset = scrollView.contentOffset.y < 0.0 ? 0.0 : scrollView.contentOffset.y
val backgroundAlpha = (contentOffsetAbsolute / (screenHeight * 1.5))
However, I don't know how to get the screen size in Jetpack Compose, or check if it's already 1.5x of the screen size, and also how to manipulate the alpha of the image so that it starts to disappear.
Below, you can see the code in question and the image I have as a background:
val list = mutableListOf<String>().apply {
for (i in 0..1000) {
add("Item $i")
}
}
setContent {
// Decorations omitted for question-readability
Image(
painter = ...,
contentScale = ContentScale.Crop,
modifier = Modifier.fillMaxWidth()
)
LazyColumn {
items(list.size) { index ->
Text(text = list[index], modifier = Modifier.padding(20.dp))
}
}
The following's the image, if it adds any significance to the question.