Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
Last active November 12, 2021 19:29
Show Gist options
  • Save EmmanuelGuther/5d6e55ccdd29be2a72981e123fa1ed3f to your computer and use it in GitHub Desktop.
Save EmmanuelGuther/5d6e55ccdd29be2a72981e123fa1ed3f to your computer and use it in GitHub Desktop.
Jetpack compose gradient background
@Composable
fun GradientView(modifier: Modifier = Modifier) {
Box(
modifier = Modifier
.background(
brush = Brush.verticalGradient(
colors = listOf(
MaterialTheme.colorScheme.primary,
MaterialTheme.colorScheme.secondary
)
)
)
) {
}
}
@Preview
@Composable
fun GradientView() {
Box(
modifier = Modifier
.background(
brush = Brush.sweepGradient(
listOf(Color.Red, Color.Blue, Color.Blue),
center = Offset(1.0f, 1.0f)
)
).fillMaxSize()
)
}
@Preview
@Composable
fun GradientView() {
Box(
modifier = Modifier
.background(
brush = Brush.sweepGradient(
0.0f to Color.DarkGray,
0.5f to Color.Blue,
1.0f to Color.Black,
center = Offset(0.0f, 100.0f)
)
).fillMaxSize()
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment