You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Jetpack Compose中BottomBar选中项的蓝色椭圆背景

移除Jetpack Compose NavigationBarItem选中项的蓝色背景方法

要去掉选中项后方的蓝色椭圆背景,只需要修改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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 02:01:30