(Android) Adding a Four Side Shadow about Surface Composable on Jetpack Compose

  Kiến thức lập trình

I’m working on designing the layout of an Android app using Jetpack Compose. While implementing the layout with the Surface composable, I’m trying to add shadows to it using the .shadow method in the modifier property. By default, it seems that only the bottom part has shadows, but I want shadows on all sides—top, bottom, left, and right. How can I modify the code to achieve this?

This is Code:

fun TodoMenu(
    onMultiFloatingStateChange: (FloatingStateType) -> Unit,
    onButtonClick: (String) -> Unit
) {
    Surface(
        modifier = Modifier
            .width(155.dp)
            .height(110.dp)
            .padding(bottom = 10.dp)
            .shadow(
                shape = RoundedCornerShape(20.dp),
                elevation = 5.dp,
                spotColor = Color(0xff9E9E9E),
                ambientColor = Color(0xffACACAC)
            )
            .background(Color.White)
    ) {
}
}

This is ScreenShot:

enter image description here

LEAVE A COMMENT