12

我想知道jetpack中的Scaffold是什么,并带有BottomAppBar示例,任何人都可以帮助我 Scaffold

4

1 回答 1

19

With1.0.x Scaffold允许您使用基本的 Material Design 布局结构实现 UI。Scaffold为最常见的顶级 Material 组件提供插槽,例如TopAppBarBottomAppBarFloatingActionButtonDrawer.

就像是:

   val scaffoldState = rememberScaffoldState()
   // Create a coroutineScope for the animation
   val coroutineScope = rememberCoroutineScope()


    Scaffold(
        scaffoldState = scaffoldState,
        drawerContent = { Text("Drawer content") },
        bottomBar = {
            BottomAppBar(cutoutShape = CircleShape) {
                IconButton(
                    onClick = {
                        coroutineScope.launch { scaffoldState.drawerState.open() }
                    }
                ) {
                    Icon(Icons.Filled.Menu, contentDescription = "....")
                }
            }
        },
        floatingActionButton = {
            ExtendedFloatingActionButton(
                text = { Text("Action") },
                onClick = { /* .... */ }
            )
        },
        floatingActionButtonPosition = FabPosition.Center,
        isFloatingActionButtonDocked = true,
        content = { innerPadding ->
            //....
        }
    )

在此处输入图像描述

于 2021-03-27T08:50:04.933 回答