2

How to change the color of the cut out for the bottom bar?

I know it takes the color from MaterialTheme.colors.background, but I don't want to change the background color for all components, only for the bottom bar. (The white color in the cut out in the picture.)

enter image description here

I have tried different things, for example setting a new theme just for the bottom bar, but that doesn't work.

val bottomBarColors = MaterialTheme.colors.copy(background = Color.LightGray)
...

bottomBar = {
    MaterialTheme(
        colors = bottomBarColors,
        typography = MaterialTheme.typography,
        shapes = MaterialTheme.shapes
    ) {
        BottomAppBar(
            cutoutShape = fabShape,
            content = {
                MyBottomNavigation(navController, bottomNavigationItems)
            })
    }
}
1
  • would you pleas share your codes? Commented Dec 29, 2022 at 5:25

2 Answers 2

3

In your case you can apply the Modifier.background to the BottomAppBar:

    bottomBar = {
        BottomAppBar(
            modifier = Modifier.background(Color.Red),
            cutoutShape = fabShape) {

            BottomNavigation {
                /* .... */
            }
        }
    }

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

how to make that color to be transparent?
-1

The solution was easier than I thought. Just add something below the bottom bar:

bottomBar = {
        Box {
            Spacer(modifier = Modifier.matchParentSize().background(color = Color.Blue))
            BottomAppBar(
                cutoutShape = fabShape,
                content = {
                    MyBottomNavigation(navController, bottomNavigationItems)
                })
    }
}

2 Comments

Check out Gabriele's answer. That is appropriate.
More official way of doing it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.