【发布时间】:2021-11-17 13:09:19
【问题描述】:
【问题讨论】:
标签: android android-jetpack-compose bottomnavigationview
【问题讨论】:
标签: android android-jetpack-compose bottomnavigationview
只需使用clip Modifier 并在顶角添加RoundedCornerShape,这里是示例代码
BottomNavigation(
backgroundColor = colorResource(id = R.color.black),
modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(15.dp, 15.dp, 0.dp, 0.dp))
)
【讨论】:
使用clip 和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 }
)
}
}
}
【讨论】: