如何使bottomappbar的浮动操作按钮透明?

rlcwz9us  于 2021-09-29  发布在  Java
关注(0)|答案(1)|浏览(368)

我正在工作 Jetpack Compose 在android应用程序中。所以我想用 BottomAppBar 以透明的 cutoutShape . 没有找到任何例子,有人能帮忙吗?😊
我想使晶圆厂周围的白色背景透明。
实际结果(不是预期结果):一个没有透明切口形状的bottomappbar
我使用的代码是:

val fabShape = RoundedCornerShape(50)
    Scaffold(
        floatingActionButton = {
            FloatingActionButton(
                onClick = {
                    navController.navigate(Routes.signUp)
                },
                shape = fabShape,
                backgroundColor = Color(0xFFFF8C00)
            ) {
                Icon(Icons.Filled.Add, "")
            }
        },
        isFloatingActionButtonDocked = true,
        floatingActionButtonPosition = FabPosition.Center,

        bottomBar = {
            BottomAppBar(
                cutoutShape = fabShape,
                content = {
                    BottomNavigation {
                        val navBackStackEntry by navController.currentBackStackEntryAsState()
                        val currentDestination = navBackStackEntry?.destination
                        items.forEachIndexed { index, screen ->
                                BottomNavigationItem(
                                   ...
                                )
                        }
                    }
                }
            )
        }
    ) { innerPadding ->
        internalView(innerPadding)
    }
93ze6v8z

93ze6v8z1#

如果您想让内容滚动到bottomappbar后面,只需删除 innerPadding 那个 Scaffold 传给 content :
不申请 innerPadding :

Scaffold(
    //...
    content = { innerPadding ->

        Column(
            Modifier
                .fillMaxWidth()
                .verticalScroll(rememberScrollState()),
            verticalArrangement = Arrangement.Bottom,
            horizontalAlignment = Alignment.CenterHorizontally) {
            Image(painterResource(id = R.drawable.xxx),"")
        }

    }
)


应用 innerPadding :

Scaffold(
    //...
    content = { innerPadding ->

        Column(
            Modifier
                .fillMaxWidth()
                .padding(innerPadding)
                .verticalScroll(rememberScrollState()),
            verticalArrangement = Arrangement.Bottom,
            horizontalAlignment = Alignment.CenterHorizontally) {
            Image(painterResource(id = R.drawable.xxx),"")
        }

    }
)

相关问题