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,
The Point is I could not find a way to make somethin like this
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 }
)
}
}
}