Christian Ricardo
04/21/2023, 11:55 PMArtem Svetlovsky
04/23/2023, 11:18 AMChristian Ricardo
04/24/2023, 1:05 AM@Composable
private fun DropShadowIcon() = Icon(
modifier = Modifier.shadow(elevation = 3.dp),
imageVector = Icons.Filled.Share,
contentDescription = "share icon",
tint = Color.White,
)
Oleksandr Balan
04/24/2023, 7:26 AMOleksandr Balan
04/24/2023, 9:43 AM@Preview
@Composable
fun IconShadow() {
val context = LocalContext.current
val iconRes = R.drawable.ic_share
val shape = remember(context, iconRes) {
val drawable = ContextCompat.getDrawable(context, iconRes)
val path = requireNotNull(drawable).toBitmap().toPath()
GenericShape { _, _ -> addPath(path.asComposePath()) }
}
Icon(
painter = painterResource(iconRes),
contentDescription = null,
tint = Color.White,
modifier = Modifier
.padding(16.dp)
.shadow(
elevation = 3.dp,
shape = shape,
),
)
}
However I am not sure how to properly convert ImageVector to Bitmap, so I did it in the “old” way through the drawable.Christian Ricardo
05/04/2023, 3:24 PM