如何移除Jetpack Compose中BottomBar选中项的蓝色椭圆背景
要去掉选中项后方的蓝色椭圆背景,只需要修改NavigationBarItemDefaults.colors中的indicatorColor,将其设置为透明色即可——这个参数正是控制选中项指示器背景的。
修改后的代码如下:
NavigationBarItem( selected = selected, onClick = onClick, icon = if (selected) selectedIcon else icon, modifier = modifier, enabled = enabled, label = label, alwaysShowLabel = alwaysShowLabel, colors = NavigationBarItemDefaults.colors( selectedIconColor = AppDefaults.navigationSelectedItemColor(), unselectedIconColor = AppDefaults.navigationContentColor(), selectedTextColor = AppDefaults.navigationSelectedItemColor(), unselectedTextColor = AppDefaults.navigationContentColor(), indicatorColor = Color.Transparent // 这里改为透明色 ) )
这样修改后,选中项就不会再显示蓝色椭圆背景了。
内容的提问来源于stack exchange,提问作者Saeed Noshadi
相关产品推荐
相关产品推荐

