Home > Enterprise >  How to make rounded bottom navigation in Android Jetpack Compose
How to make rounded bottom navigation in Android Jetpack Compose

Time:11-18

I want to make a Bottom naviation in Android Jetpack compose but in every source I found, The navigation built with compose is normal, flat one Just like This, enter image description here

The Point is I could not find a way to make somethin like this enter image description here

How can I do just a thing ? Thanks

CodePudding user response:

Just use clip Modifier and add RoundedCornerShape with the top corners , here is sample code

BottomNavigation(
            backgroundColor = colorResource(id = R.color.black),
            modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(15.dp, 15.dp, 0.dp, 0.dp))
        )

CodePudding user response:

Use clip and RoundedCornerShap:

var selectedItem by remember { mutableStateOf(0) }
val items = listOf("Songs", "Artists", "Playlists")

Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.BottomStart) {
    BottomNavigation(modifier = Modifier.clip(shape = RoundedCornerShape(topStart = 20.dp, topEnd = 20.dp))) {
        items.forEachIndexed { index, item ->
            BottomNavigationItem(
                icon = { Icon(Icons.Filled.Favorite, contentDescription = null) },
                label = { Text(item) },
                selected = selectedItem == index,
                onClick = { selectedItem = index }
            )
        }
    }
}
  • Related