how to remove shade on compose view?
Asked Answered
C

4

6

I use compose button in android view, but there is some shade at the bottom. How can I remove it?

    @Composable
fun VisibilityAnimationFAB() {
    var expanded by remember { mutableStateOf(true) }
    FloatingActionButton(
        onClick = { expanded = !expanded },
        modifier = Modifier
    ) {
        Row(Modifier.padding(start = 16.dp, end = 16.dp)) {
            Icon(
                vectorResource(id = R.drawable.ic_twitter),
                Modifier.align(Alignment.CenterVertically)
            )
            AnimatedVisibility(
                expanded,
                modifier = Modifier.align(Alignment.CenterVertically)
            ) {
                androidx.compose.material.Text(modifier = Modifier.padding(start = 8.dp), text = "Tweet")
            }
        }
    }

}

enter image description here

Catechu answered 3/1, 2021 at 12:53 Comment(0)
A
7

You can use the elevation attribute in the FloatingActionButton

FloatingActionButton(
        onClick = { expanded = !expanded },
        modifier = Modifier,
        elevation = FloatingActionButtonDefaults.elevation(0.dp,0.dp)
    ){ /* .. */ }
Awhile answered 7/4, 2021 at 14:11 Comment(0)
O
5

Use the elevation parameter in FloatingActionButton. In material design, elevation is the relative distance between two surfaces along the z-axis. Shadows make differences in surface elevation perceptible. (source)

You have to pass FloatingActionButtonElevation, which can be created using the elevation(...) method.

FloatingActionButton(
  elevation = elevation(
    defaultElevation = 0.dp
    pressedElevation = 0.dp
  ),
  // ...
) {
  // ...
}
Omor answered 4/1, 2021 at 8:37 Comment(0)
O
4

this code disable all shadows

    FloatingActionButton(
        onClick = { expanded = !expanded },
        modifier = Modifier,
        elevation = null
    )
Obstructionist answered 24/11, 2021 at 8:45 Comment(1)
Thank you!! This one worked perfectly! elevation = nullRosado
B
0

You can write:

FloatingActionButton(
            onClick = {},              
            elevation = FloatingActionButtonDefaults.elevation(
                defaultElevation = 0.dp
            )
        )
Budd answered 28/1, 2023 at 8:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.