BottomSheetScaffold
fun BottomSheetScaffold(
sheetContent: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
scaffoldState: BottomSheetScaffoldState = rememberBottomSheetScaffoldState(),
topBar: (@Composable () -> Unit)? = null,
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) },
floatingActionButton: (@Composable () -> Unit)? = null,
floatingActionButtonPosition: FabPosition = FabPosition.End,
sheetGesturesEnabled: Boolean = true,
sheetShape: Shape = MaterialTheme.shapes.large,
sheetElevation: Dp = BottomSheetScaffoldDefaults.SheetElevation,
sheetBackgroundColor: Color = MaterialTheme.colors.surface,
sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
sheetPeekHeight: Dp = BottomSheetScaffoldDefaults.SheetPeekHeight,
drawerContent: @Composable (ColumnScope.() -> Unit)? = null,
drawerGesturesEnabled: Boolean = true,
drawerShape: Shape = MaterialTheme.shapes.large,
drawerElevation: Dp = DrawerDefaults.Elevation,
drawerBackgroundColor: Color = MaterialTheme.colors.surface,
drawerContentColor: Color = contentColorFor(drawerBackgroundColor),
drawerScrimColor: Color = DrawerDefaults.scrimColor,
backgroundColor: Color = MaterialTheme.colors.background,
contentColor: Color = contentColorFor(backgroundColor),
content: @Composable (PaddingValues) -> Unit
)
- sheetContent 底部抽屜的內(nèi)容
- drawerState可以去控制左邊抽屜的狀態(tài)
- bottomSheetState 可以去控制底部抽屜的狀態(tài)
- snackbarHostState 可以控制Snackbar的狀態(tài)
- topBar 頂部控件
- floatingActionButton 浮動(dòng)的button
- floatingActionButtonPosition 設(shè)置floatingActionButton的按鈕的位置胜卤。是在底部居中還是再右下角士鸥,有一半會(huì)蓋在sheetContent上面
- sheetGesturesEnabled 是否能通過(guò)手指滑動(dòng)去打開(kāi)和關(guān)閉底部的抽屜
- sheetShape 底部抽屜的形狀
- sheetElevation 底部抽屜的陰影
- sheetBackgroundColor 底部抽屜的背景顏色
- sheetContentColor 底部抽屜的內(nèi)容顏色
- sheetPeekHeight 是底部抽屜的初始的高度
- drawerContent 左邊抽屜的內(nèi)容
- drawerGesturesEnabled 是否能通過(guò)手指拖動(dòng)的形式去打開(kāi)和關(guān)閉左邊的抽屜
- drawerShape 左邊抽屜的形狀
- drawerElevation 左邊抽屜的陰影
- drawerBackgroundColor 左邊抽屜的背景顏色
- drawerContentColor 左邊抽屜的內(nèi)容的顏色
- drawerScrimColor 左邊抽屜打開(kāi)的時(shí)候呻征,右邊剩余部分的顏色值
- backgroundColor BottomSheetScaffold控件的背景顏色
- contentColor BottomSheetScaffold控件的內(nèi)容的顏色
- content BottomSheetScaffold控件包含的內(nèi)容
ModalBottomSheetLayout
fun ModalBottomSheetLayout(
sheetContent: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
sheetState: ModalBottomSheetState =
rememberModalBottomSheetState(Hidden),
sheetShape: Shape = MaterialTheme.shapes.large,
sheetElevation: Dp = ModalBottomSheetDefaults.Elevation,
sheetBackgroundColor: Color = MaterialTheme.colors.surface,
sheetContentColor: Color = contentColorFor(sheetBackgroundColor),
scrimColor: Color = ModalBottomSheetDefaults.scrimColor,
content: @Composable () -> Unit
)
- sheetContent 底部抽屜的內(nèi)容
- modifier 修飾符
- sheetState 設(shè)置狀態(tài)。顯示和隱藏底部抽屜
- 默認(rèn)實(shí)現(xiàn)是rememberModalBottomSheetState(ModalBottomSheetValue.Hidden)叼丑。
- ModalBottomSheetValue.Hidden是隱藏
- ModalBottomSheetValue.Expanded打開(kāi)
- ModalBottomSheetValue.HalfExpanded 打開(kāi)一半
- sheetShape 設(shè)置底部抽屜形狀
- sheetElevation 設(shè)置底部抽屜的陰影
- sheetBackgroundColor 設(shè)置底部抽屜的背景顏色
- sheetContentColor 設(shè)置底部抽屜內(nèi)容的顏色
- scrimColor 設(shè)置底部抽屜打開(kāi)的時(shí)候关翎,頂部剩余部分的顏色
- content ModalBottomSheetLayout的內(nèi)容
BackdropScaffold
fun BackdropScaffold(
appBar: @Composable () -> Unit,
backLayerContent: @Composable () -> Unit,
frontLayerContent: @Composable () -> Unit,
modifier: Modifier = Modifier,
scaffoldState: BackdropScaffoldState = rememberBackdropScaffoldState(Concealed),
gesturesEnabled: Boolean = true,
peekHeight: Dp = BackdropScaffoldDefaults.PeekHeight,
headerHeight: Dp = BackdropScaffoldDefaults.HeaderHeight,
persistentAppBar: Boolean = true,
stickyFrontLayer: Boolean = true,
backLayerBackgroundColor: Color = MaterialTheme.colors.primary,
backLayerContentColor: Color = contentColorFor(backLayerBackgroundColor),
frontLayerShape: Shape = BackdropScaffoldDefaults.frontLayerShape,
frontLayerElevation: Dp = BackdropScaffoldDefaults.FrontLayerElevation,
frontLayerBackgroundColor: Color = MaterialTheme.colors.surface,
frontLayerContentColor: Color = contentColorFor(frontLayerBackgroundColor),
frontLayerScrimColor: Color = BackdropScaffoldDefaults.frontLayerScrimColor,
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost(it) }
)
appBar 頂部的控件,
backLayerContent 顯示在后面被遮擋的內(nèi)容
frontLayerContent 顯示在前面的內(nèi)容
modifier 修飾符
scaffoldState 狀態(tài)鸠信∽萸蓿可以設(shè)置snackbar的狀態(tài)。還可以設(shè)置BackdropScaffoldState的狀態(tài)症副。有BackdropValue.Concealed. 表示隱藏了后一層店雅,而激活了前一層
跟BackdropValue.Revealed 表示后一層顯示政基,前一層隱藏
gesturesEnabled 可否可用通過(guò)手指拖動(dòng)的形式顯示和隱藏前后界面
peekHeight 前面的界面舉例頂部的距離贞铣,也可以理解成后面的界面默認(rèn)露出顯示的高度闹啦。默認(rèn)是56dp
headerHeight
persistentAppBar 當(dāng)為true的時(shí)候,不管顯示還是隱藏后面的界面辕坝,appBar都一直顯示的窍奋。如果值為false,則顯示后面的界面的時(shí)候酱畅,appBar會(huì)隱藏
stickyFrontLayer 當(dāng)為true的時(shí)候琳袄,前面的界面之后下拉到后面界面的內(nèi)容高度位置。為false 的時(shí)候纺酸,前面的界面可以一直下拉到屏幕底部(試試效果就知道)
backLayerBackgroundColor 后面界面的背景顏色
backLayerContentColor 后面界面的內(nèi)容的顏色
frontLayerShape 前面界面的形狀
frontLayerElevation 前面界面的陰影
frontLayerBackgroundColor 前面界面的背景顏色
frontLayerContentColor 前面界面的內(nèi)容的顏色
frontLayerScrimColor 前面界面下拉時(shí)窖逗,頂部預(yù)留出來(lái)的空白的顏色
snackbarHost 設(shè)置Snackbar的
TopAppBar
fun TopAppBar(
modifier: Modifier = Modifier,
backgroundColor: Color = MaterialTheme.colors.primarySurface,
contentColor: Color = contentColorFor(backgroundColor),
elevation: Dp = AppBarDefaults.TopAppBarElevation,
contentPadding: PaddingValues = AppBarDefaults.ContentPadding,
content: @Composable RowScope.() -> Unit
)
backgroundColor 背景顏色
contentColor 內(nèi)容的顏色
elevation 陰影
contentPadding 內(nèi)容邊距
可通過(guò)PaddingValue設(shè)置,也可使用默認(rèn)AppBarDefaults.ContentPadding
content 內(nèi)容控件
BottomAppBar
fun BottomAppBar(
modifier: Modifier = Modifier,
backgroundColor: Color = MaterialTheme.colors.primarySurface,
contentColor: Color = contentColorFor(backgroundColor),
cutoutShape: Shape? = null,
elevation: Dp = AppBarDefaults.BottomAppBarElevation,
contentPadding: PaddingValues = AppBarDefaults.ContentPadding,
content: @Composable RowScope.() -> Unit
)
backgroundColor 背景顏色
contentColor 內(nèi)容的顏色
cutoutShape 形狀
elevation 陰影
contentPadding 內(nèi)容邊距
可通過(guò)PaddingValue設(shè)置餐蔬,也可使用默認(rèn)AppBarDefaults.ContentPadding
content 內(nèi)容控件
Snackbar
fun Snackbar(
modifier: Modifier = Modifier,
action: @Composable (() -> Unit)? = null,
actionOnNewLine: Boolean = false,
shape: Shape = MaterialTheme.shapes.small,
backgroundColor: Color = SnackbarDefaults.backgroundColor,
contentColor: Color = MaterialTheme.colors.surface,
elevation: Dp = 6.dp,
content: @Composable () -> Unit
)
modifier 修飾符
action 行為的內(nèi)容是什么控件
actionOnNewLine 表示action內(nèi)容是否在新的一行碎紊,為true為另為一行,否則會(huì)和content的內(nèi)容疊在一起
shape形狀 默認(rèn)是MaterialTheme.shapes.small 也就是RoundedCornerShape(4.dp)
backgroundColor 設(shè)置背景顏色
contentColor 設(shè)置內(nèi)容的顏色
elevation設(shè)置陰影
content 內(nèi)容是什么控件
ModalDrawer
fun ModalDrawer(
drawerContent: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
drawerState: DrawerState = rememberDrawerState(DrawerValue.Closed),
gesturesEnabled: Boolean = true,
drawerShape: Shape = MaterialTheme.shapes.large,
drawerElevation: Dp = DrawerDefaults.Elevation,
drawerBackgroundColor: Color = MaterialTheme.colors.surface,
drawerContentColor: Color = contentColorFor(drawerBackgroundColor),
scrimColor: Color = DrawerDefaults.scrimColor,
content: @Composable () -> Unit
)
drawerContent 左邊的內(nèi)容
modifier 修飾符 Modifier用法詳解
drawerState ModalDrawer的狀態(tài) 有DrawerValue.open打開(kāi)樊诺,DrawerValue.Closed關(guān)閉
gesturesEnabled 是否支持手勢(shì)去打開(kāi)和關(guān)閉抽屜
drawerShape 形狀
drawerElevation 陰影
drawerBackgroundColor 背景顏色
drawerContentColor 內(nèi)容的顏色
scrimColor 當(dāng)左邊drawer控件顯示的時(shí)候仗考,右邊余留出來(lái)的顏色
BottomDrawercontent ModalDrawer的內(nèi)容
BottomDrawer
fun BottomDrawer(
drawerContent: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
drawerState: BottomDrawerState = rememberBottomDrawerState(BottomDrawerValue.Closed),
gesturesEnabled: Boolean = true,
drawerShape: Shape = MaterialTheme.shapes.large,
drawerElevation: Dp = DrawerDefaults.Elevation,
drawerBackgroundColor: Color = MaterialTheme.colors.surface,
drawerContentColor: Color = contentColorFor(drawerBackgroundColor),
scrimColor: Color = DrawerDefaults.scrimColor,
content: @Composable () -> Unit
)
drawerContent 底部抽屜的內(nèi)容
modifier 修飾符
drawerState 抽屜的狀態(tài),BottomDrawerValue.Open 打開(kāi)一半
BottomDrawerValue.Closed 關(guān)閉词爬,BottomDrawerValue.Expanded 是完全打開(kāi)
gesturesEnabled 是否支持手勢(shì)去打開(kāi)和關(guān)閉抽屜
drawerShape 抽屜形狀
drawerElevation 抽屜陰影
drawerBackgroundColor 抽屜背景顏色
drawerContentColor 抽屜內(nèi)容顏色
scrimColor 抽屜打開(kāi)時(shí)候秃嗜,頂部剩余空間的顏色
content BottomDrawer的內(nèi)容