【发布时间】:2021-12-24 10:49:20
【问题描述】:
如果我在底部导航的底部栏中添加浮动操作按钮作为扩展,菜单将被位置覆盖。 如果我设置在中心,您可以看到两个菜单。 但如果我把它留作结束,你只能看到一个菜单。 当我将其设置为结束时,我想同时查看两个菜单。
这是我的代码
Scaffold(
topBar = {
if (menu.name != null) {
TopAppBarCompose(title = menu.name)
}
},
floatingActionButton = {
FloatingActionButton(
onClick = {
val route = Screen.BarcodeScan.route
onNavigateToBarcodeScreen(route)
},
shape = RoundedCornerShape(50),
backgroundColor = MaterialTheme.colors.primary
) {
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center
) {
Icon(
imageVector = Icons.Default.QrCodeScanner,
contentDescription = "BarcodeScan",
modifier = Modifier.padding(start = 30.dp, top = 20.dp, bottom = 20.dp, end = 5.dp)
)
Text(
text = "Scan",
fontSize = 24.sp,
fontWeight = FontWeight.Bold,
modifier = Modifier.padding(start = 5.dp, top = 20.dp, bottom = 20.dp, end = 30.dp)
)
}
}
},
isFloatingActionButtonDocked = true,
floatingActionButtonPosition = FabPosition.End,
bottomBar = {
BottomAppBar(
cutoutShape = RoundedCornerShape(50),
content = {
BottomNavigation {
BottomNavigationItem(
selected = selectedItem.value == "send",
onClick = {
content.value = "Send Screen"
selectedItem.value = "send"
},
icon = {
Icon(Icons.Filled.SwapVert, contentDescription = "send")
},
label = { Text(text = "send") },
alwaysShowLabel = false
)
BottomNavigationItem(
selected = selectedItem.value == "input",
onClick = {
content.value = "input Screen"
selectedItem.value = "input"
},
icon = {
Icon(Icons.Filled.Create, contentDescription = "input")
},
label = { Text(text = "Input") },
alwaysShowLabel = false
)
}
}
)
}
)
当我设置在中心时,我可以看到两个菜单
但是我设置了扩展的fab按钮结束,它会如下。
我想将扩展 fab 按钮的位置设置为 end 并查看两个菜单。有办法换地方吗?
ps.图片只是上传帮助理解。
【问题讨论】:
-
这似乎是一个错误。根据Material Guidelines,在使用
FabPosition.End时,项目必须“与 FAB 的相对边缘对齐”。我建议你report this。 -
@PhilipDukhov 谢谢,如果不使用扩展 fab 按钮,一般 fab 按钮也会导致相同的情况。根据文档,它肯定应该是左对齐的,但我想知道为什么不是。如果有官方的例子,我想查一下。
标签: android-jetpack-compose floating-action-button