BottomNavigation
常用于Scaffold 中 bottomBar 参数使用
预览
代码
val items = listOf("Home","Search","Profile","Settings")val icons = listOf(Icons.Filled.Home,Icons.Filled.Search,Icons.Filled.AccountCircle,Icons.Filled.Settings,)var selectedIndex by remember { mutableStateOf(0) }//Modifier.navigationBarsPadding() 解决系统虚拟导航栏遮住BottomNavigationBottomNavigation(modifier = Modifier.navigationBarsPadding()) {items.forEachIndexed { index, itemText ->BottomNavigationItem(icon = {Icon(icons[index],tint = if (selectedIndex == index) Color.White else Color.Black,contentDescription = null)},label = { Text(text = itemText, color = if (selectedIndex == index) Color.White else Color.Black) },selected = selectedIndex == index,selectedContentColor = Color.Cyan,unselectedContentColor = Color.Blue,onClick = {selectedIndex = index})}}