I was curios how it will work, so I have tried steps from above and it creates a small subtle shadow that looks fine as for me 😄
@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.