Last active
September 23, 2022 15:17
-
-
Save mazzouzi/e5dc70b4db33f368016f541b92924162 to your computer and use it in GitHub Desktop.
Header composable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private val headerHeight = 275.dp | |
@Composable | |
private fun Header() { | |
val headerHeightPx = with(LocalDensity.current) { headerHeight.toPx() } | |
Box(modifier = Modifier.fillMaxWidth().height(headerHeight)) { | |
Image( | |
painter = painterResource(id = R.drawable.bg_pexel), | |
contentDescription = "", | |
contentScale = ContentScale.FillBounds | |
) | |
Box( | |
Modifier | |
.fillMaxSize() | |
.background( | |
brush = Brush.verticalGradient( | |
colors = listOf(Color.Transparent, Color(0xAA000000)), | |
startY = 3 * headerHeightPx / 4 // to wrap the title only | |
) | |
) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment