Skip to content

Instantly share code, notes, and snippets.

@muhammedesadcomert
Created January 10, 2024 12:30
Show Gist options
  • Save muhammedesadcomert/852e83f2027ca6eea435eeea2efeeec6 to your computer and use it in GitHub Desktop.
Save muhammedesadcomert/852e83f2027ca6eea435eeea2efeeec6 to your computer and use it in GitHub Desktop.
Creating Shimmer Effect in Jetpack Compose
val shimmer = rememberShimmer(
shimmerBounds = ShimmerBounds.View, theme = defaultShimmerTheme.copy(
blendMode = BlendMode.DstOut,
shaderColors = listOf(
MaterialTheme.colorScheme.surface.copy(alpha = 0f),
MaterialTheme.colorScheme.surface.copy(alpha = 0.5f),
MaterialTheme.colorScheme.surface.copy(alpha = 0f),
),
shaderColorStops = listOf(0.0f, 0.5f, 1.0f)
)
)
Button(
modifier = Modifier
.fillMaxWidth()
.shimmer(shimmer),
contentPadding = PaddingValues(12.dp),
onClick = {
// Your onClick implementation
}
) {
Text(text = stringResource(R.string.go_premium), style = TextStyle(fontSize = 16.sp, fontWeight = FontWeight.SemiBold))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment