小编Jua*_*uez的帖子

使用 Material 3 减少导航栏中的填充

我正在使用新的 Material 3 NavigationBar 和 NavigationBarItem 组件,我希望 NavigationBar 更薄,因为默认的太大了。我想要一款类似于 Gmail 或云端硬盘的产品(请参阅最后的图片进行比较)。使图标变小不起作用,也无法更改所有可用的填充(Icon、NavigationBar 和 NavigationBarItem)。

这是可组合代码,如果我更改导航栏高度(使用修改器),则会发生这种情况: 在此输入图像描述

我主要想删除标签和底部之间的空间,以及顶部和图标之间的空间。

@Composable
fun MyAppBottomBar(navController: NavController, tabs: Array<MenuBottom>) {
    val navBackStackEntry by navController.currentBackStackEntryAsState()
    val currentRoute = navBackStackEntry?.destination?.route ?: MenuBottom.INICIO.route
    val rutas = remember { MenuBottom.values().map { it.route } }
    if (currentRoute in rutas) {
        NavigationBar(containerColor = elevation01) {
            tabs.forEachIndexed { index, item ->
                NavigationBarItem(
                    selected = currentRoute == item.route,
                    onClick = {
                        if (item.route != currentRoute) {
                            navController.navigate(item.route) {
                                popUpTo(navController.graph.startDestinationId) {
                                    saveState = true
                                }
                                launchSingleTop = …
Run Code Online (Sandbox Code Playgroud)

android kotlin material-components-android android-jetpack-compose

7
推荐指数
1
解决办法
2739
查看次数