Skip to content

Instantly share code, notes, and snippets.

@Mikkareem
Created October 28, 2023 13:40
Show Gist options
  • Save Mikkareem/f7fc3f7e8cb967f69007f9a779367459 to your computer and use it in GitHub Desktop.
Save Mikkareem/f7fc3f7e8cb967f69007f9a779367459 to your computer and use it in GitHub Desktop.
Glassy Feel of Image in Jetpack Compose
@Preview
@Composable
private fun GlassyImage() {
Box(
modifier = Modifier,
contentAlignment = Alignment.Center
) {
Image(
painter = painterResource(id = R.drawable.sample_profile1),
contentDescription = null,
// Play Around with the scale to adjust the aspect ratio
contentScale = FixedScale(1.3f)
)
Image(
painter = painterResource(id = R.drawable.sample_profile1),
contentDescription = null,
contentScale = FixedScale(1f),
modifier = Modifier.padding(32.dp)
.shadow(
elevation = 24.dp,
shape = RoundedCornerShape(24.dp)
)
.graphicsLayer {
renderEffect = BlurEffect(
radiusX = 1.dp.toPx(),
radiusY = 1.dp.toPx()
)
shape = RoundedCornerShape(24.dp)
clip = true
}
)
}
}
@Mikkareem
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment