android 什么是脚手架?Jetpack组合

thtygnil  于 2023-02-17  发布在  Android
关注(0)|答案(1)|浏览(233)

我想知道jetpack中的Scaffold是什么,用BottomAppBar示例编写,有人能帮我吗Scaffold

sr4lhrrt

sr4lhrrt1#

    • 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 ->
            //....
        }
    )

相关问题