Sae*_*adi 6 android android-jetpack-compose android-jetpack-compose-material3 material3
我想删除所选项目后面的蓝色椭圆形颜色。我怎样才能做到这一点?
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 = AppDefaults.navigationIndicatorColor()
)
)
Run Code Online (Sandbox Code Playgroud)
Gab*_*tti 10
indicatorColor
指示器的颜色由NavigationBarItem
.
要删除它,您必须应用containerColor
与NavigationBar
.
如果您使用默认值(containerColor
=surface
颜色),则必须计算应用于不同高度的表面色调颜色containerColor
。
就像是:
NavigationBarItem(
icon = { androidx.compose.material3.Icon(Icons.Filled.Favorite, contentDescription = item) },
label = { androidx.compose.material3.Text(item) },
selected = selectedItem == index,
onClick = { selectedItem = index },
colors = androidx.compose.material3.NavigationBarItemDefaults
.colors(
selectedIconColor = Red,
indicatorColor = MaterialTheme.colorScheme.surfaceColorAtElevation(LocalAbsoluteTonalElevation.current)
)
)
Run Code Online (Sandbox Code Playgroud)
在其他情况下只需使用相同的颜色:
NavigationBar(
containerColor = Yellow
){
items.forEachIndexed { index, item ->
NavigationBarItem(
icon = { androidx.compose.material3.Icon(Icons.Filled.Favorite, contentDescription = item) },
label = { androidx.compose.material3.Text(item) },
selected = selectedItem == index,
onClick = { selectedItem = index },
colors = androidx.compose.material3.NavigationBarItemDefaults
.colors(
selectedIconColor = Red,
indicatorColor = Yellow )
)
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3155 次 |
最近记录: |