Skip to content

Instantly share code, notes, and snippets.

@abhishekBansal
Created March 25, 2022 09:48
Show Gist options
  • Select an option

  • Save abhishekBansal/af2f7cd0e6cc373e7770159f687ae2f3 to your computer and use it in GitHub Desktop.

Select an option

Save abhishekBansal/af2f7cd0e6cc373e7770159f687ae2f3 to your computer and use it in GitHub Desktop.
Compose Infinite Moving gradient
val infiniteTransition = rememberInfiniteTransition()
val animationDuration = 5000
val color1 by infiniteTransition.animateColor(
initialValue = Color.Green,
targetValue = Color.Cyan,
animationSpec = infiniteRepeatable(
animation = tween(animationDuration, easing = FastOutSlowInEasing),
repeatMode = RepeatMode.Reverse
)
)
val color2 by infiniteTransition.animateColor(
initialValue = Color.Cyan,
targetValue = Color.Green,
animationSpec = infiniteRepeatable(
animation = tween(animationDuration, easing = LinearOutSlowInEasing),
repeatMode = RepeatMode.Reverse
)
)
val radial = Brush.linearGradient(listOf(color1, color2))
Box(
modifier = Modifier
.background(radial)
.fillMaxHeight()
.fillMaxWidth()
.padding(24.dp),
contentAlignment = Alignment.Center
) {
val text= Text(
text = fact.fact,
textAlign = TextAlign.Center,
fontSize = 22.sp,
fontWeight = FontWeight.SemiBold,
modifier = Modifier.background(Color.Transparent)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment