如何修复顶部栏和底部栏未填满其容器。topbar 和 bottombar 分别使用默认的 Elevation
您可以看到顶部栏没有填充最大宽度并且有阴影,而底部栏有自己的文本
Scaffold(
topBar = {
TopAppBar(
title = { Text( text = "TEST" ) },
actions = {
IconButton(
onClick = { },
) {
Icon(
imageVector = Icons.Filled.AccountCircle,
contentDescription = null
)
}
},
)
},
bottomBar = {
BottomNavigation
{
val navBackStackEntry by bottomAppBarNavController.currentBackStackEntryAsState()
val currentDestination = navBackStackEntry?.destination
bottomBarItems.forEach { mainRoute ->
BottomNavigationItem(
selected = currentDestination?.hierarchy?.any { it.route == mainRoute.route } == true,
icon = {
Icon(
imageVector = mainRoute.icon,
contentDescription = stringResource(id = mainRoute.resourceId),
)
},
label = { Text( text = stringResource(id = mainRoute.resourceId), ) },
onClick = { },
alwaysShowLabel = false // This hides the title for the unselected items
)
}
}
}
){
}