【发布时间】:2021-11-07 13:54:08
【问题描述】:
@Composable
fun BottomNavigationBar(items: List<BottomNavItem>, navController: NavController, onItemClick: (BottomNavItem) -> Unit){
val selectedScreen = navController.currentBackStackEntryAsState()
BottomNavigation(
modifier = Modifier.fillMaxWidth(),
backgroundColor = Color.Transparent,
) {
items.forEach { item ->
val selected = item.route == selectedScreen.value?.destination?.route
BottomNavigationItem(
selected = selected,
onClick = { onItemClick(item) },
selectedContentColor = colorResource(id = R.color.button_background_light_blue),
unselectedContentColor = Color.Gray,
icon = {
Column(horizontalAlignment = CenterHorizontally) {
Icon(imageVector = item.icon, contentDescription = item.name)
if(selected) {
Text(text = item.name, textAlign = TextAlign.Center, fontSize = 10.sp)
}
}
}
)
}
}
}
tbh 我没有找到任何关于(这只是我假设的)一个包含图标或任何接近图标的框,我可以添加什么来删除那个“框”?
【问题讨论】:
标签: android kotlin user-interface transparency android-jetpack-compose