我想在Android Jetpack compose中做一个底部导航,但在我发现的每个源代码中,用compose构建的导航都是正常的,就像这样。
重点是我找不到一种方法来制作这样的东西
我怎么能只做一件事呢?谢谢
发布于 2021-11-17 13:30:54
只需使用clip
Modifier
并添加带有顶角的RoundedCornerShape
,以下是示例代码
BottomNavigation(
backgroundColor = colorResource(id = R.color.black),
modifier = Modifier.fillMaxWidth().clip(RoundedCornerShape(15.dp, 15.dp, 0.dp, 0.dp))
)
发布于 2021-11-17 13:30:45
使用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 }
)
}
}
}
https://stackoverflow.com/questions/70005009
复制相似问题