Jetpack Compose 中的 Material3 导航栏出现错误波纹
当我在 Jetpack Compose 中使用 Material3 NavigationBar
时,我得到了错误的矩形波纹效果,如下所示:
Material3 库版本:1.0.0-alpha06
代码:
NavigationBar(modifier = Modifier.navigationBarsPadding()) {
NavigationBarItem(
selected = ...,
onClick = {
navController.navigate(ScreenComponents(context).mainScreen) {
launchSingleTop = true
}
},
icon = {
...
},
alwaysShowLabel = false,
label = {
Text(text = ..., color = MaterialTheme.colorScheme.onSurface)
}
)
// ...
When I use Material3 NavigationBar
in Jetpack Compose I get wrong rectangular ripple effect like this:
Material3 library version: 1.0.0-alpha06
Code:
NavigationBar(modifier = Modifier.navigationBarsPadding()) {
NavigationBarItem(
selected = ...,
onClick = {
navController.navigate(ScreenComponents(context).mainScreen) {
launchSingleTop = true
}
},
icon = {
...
},
alwaysShowLabel = false,
label = {
Text(text = ..., color = MaterialTheme.colorScheme.onSurface)
}
)
// ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这不是一个错误。它遵循材料指南。
It is not a bug. It follows the material guidelines.
自从 @Gabriele Mariotti 的答案以来,他们似乎已经更改了指导图像,现在波纹只出现在“药丸”上。
有一种简单的方法可以完全禁用波纹,但不能将其隔离到药丸上。希望他们在 M3 可组合项退出 alpha 之前更新此内容。
They seem to have changed the guideline images since the answer from @Gabriele Mariotti and now the ripple only appears on the 'pill'.
There is an easy way to disable the ripple entirely, but not to isolate it to the pill. Hopefully they update this before the M3 composables come out of alpha.
在 NavigationBarItem 中,我使用此修改器来更改波纹的形状
In NavigationBarItem I use this modifier to change the shape of the ripple
我设法通过指定自定义交互源来消除对药丸的连锁反应:
并将此交互源作为参数传递:
I managed to remove a ripple effect on the pill by specifying a custom interaction source:
and passing this interaction source as an argument: