Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TopAppBar does not drop shadow

I have a TopAppBar within my Scaffold in my composable, but it is not droping a shadow as it is supposed to do:

@Composable
fun MainScreen(navController: NavController) {
    Scaffold(
        topBar = {
            TopAppBar(
                title = { Text(text = stringResource(id = R.string.appName)) },
            )
        }
    ) {
        Text("Composable content")
    }
}

Even if I manually set an elevation it does not drop any shadow:

    TopAppBar(
        title = { Text(text = stringResource(id = R.string.appName)) },
        elevation = 4.dp
    )

What needs to be done so the AppBar drops a shadow?

like image 851
svprdga Avatar asked Aug 27 '26 11:08

svprdga


1 Answers

Can you try this in Box ?

enter image description here

Surface(
        modifier = Modifier.fillMaxSize(),
        color = Color.White,
    ) {
        Column (){
            Box(modifier = Modifier.height(80.dp)) {
                TopAppBar(
                    backgroundColor = Color.White,
                    title = { Text("Title") },
                    elevation = 10.dp
                )
            }
            Text(text = "Composable content", style = TextStyle(
                color = Color.Black
            ))
        }
    }
like image 182
tugrul altun Avatar answered Aug 29 '26 01:08

tugrul altun



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!