Compose BottomAppBar
-
BottomAppBar 介绍
用于底部引用栏在移动屏幕底部显示导航和关键操作。
h
@Composable
fun BottomAppBar(
modifier: Modifier =Modifier,
containerColor: Color =BottomAppBarDefaults. containerColor,
contentColor: Color =contentColorFor (containerColor),
tonalElevation: Dp =BottomAppBarDefaults. ContainerElevation,
contentPadding: PaddingValues =BottomAppBarDefaults. ContentPadding,
windowInsets: WindowInsets =BottomAppBarDefaults. windowInsets,
content: @Composable RowScope. () -> Unit
): Unit
参数解释:
参数 | |
---|---|
modifier: Modifier =Modifier | 用于此BottomAppBar的Modifier |
containerColor: Color =BottomAppBarDefaults. containerColor | 用于此BottomAppBar 的背景颜色,使用Color。Transparent 时没有颜色,透明。 |
contentColor: Color =contentColorFor (containerColor) | 此 BottomAppBar 中内容的首选颜色。默认为 的匹配内容颜色,如果不是主题中的颜色,则默认为当前颜色。 |
tonalElevation: Dp =BottomAppBarDefaults. ContainerElevation | 当半透明的原色叠加层被应用在容器的顶部时。色调提升值越高,浅色主题的颜色越深,深色主题的颜色越浅。 |
contentPadding: PaddingValues =BottomAppBarDefaults. ContentPadding | 填充 |
windowInsets: WindowInsets =BottomAppBarDefaults. windowInsets | 应用栏将遵循的窗口插图 |
content: @Composable RowScope. () -> Unit | 此 BottomAppBar 的内容。此处的默认布局是 ,因此其中的内容将水平放置。 |
@Composable
fun BottomAppBar (
actions: @Composable RowScope. () -> Unit,
modifier: Modifier =Modifier,
floatingActionButton: (@Composable () -> Unit)? =null.
containerColor: Color =BottomAppBarDefaults. containerColor,
contentColor: Color =contentColorFor (containerColor),
tonalElevation: Dp =BottomAppBarDefaults. ContainerElevation,
contentPadding: PaddingValues =BottomAppBarDefaults. ContentPadding,
windowInsets: WindowInsets =BottomAppBarDefaults. windowInsets
: Unit
额外的参数解释 :
参数 | |
---|---|
actions: @Composable RowScope. () -> Unit | 此 BottomAppBar 的图标内容。此处的默认布局是 ,因此其中的内容将水平放置。 |
floatingActionButton: (@Composable () -> Unit)? =null | 此 BottomAppBar 末尾的可选浮动操作按钮 |
@ExperimentalMaterial3Api
@Composable
fun BottomAppBar (
modifier: Modifier =Modifier,
containerColor: Color =BottomAppBarDefaults. containerColor,
contentColor: Color =contentColorFor (containerColor),
tonalElevation: Dp =BottomAppBarDefaults. ContainerElevation,
contentPadding: PaddingValues =BottomAppBarDefaults. ContentPadding,
windowInsets: WindowInsets =BottomAppBarDefaults. windowInsets,
scrollBehavior: BottomAppBarScrollBehavior? =null,
content: @Composable RowScope. () -> Unit
): Unit
额外参数解释:
参数 | |
---|---|
scrollBehavior: BottomAppBarScrollBehavior? =null | 保存各种偏移值,此底部应用栏将应用这些偏移值来设置其高度。滚动行为旨在与滚动内容结合使用,以在内容滚动时更改底部应用栏外观。 |
content: @Composable RowScope. () -> Unit | 此 BottomAppBar 的内容。此处的默认布局是 ,因此其中的内容将水平放置。 |
@ExperimentalMaterial3Api
fun BottomAppBarState (
initialHeightOffsetLimit: Float,
initialHeightOffset: Float,
initialContentOffset: Float
): BottomAppBarState
参数解释 :
参数 | |
---|---|
initialHeightOffsetLimit: Float | HeightOffsetLimit的初始值,表示滚动可滚动内容时允许底部应用栏折叠的像素限制。 |
initialHeightOffset: Float | HeightOffset的初始值,初始偏移高度偏移应介于 0 和 HeightOffsetLimit之间。 |
initialContentOffset: Float | ContentOffset的初始值。 |
-
BottomSheetScaffold
@Composable
@ExperimentalMaterial3Api
fun BottomSheetScaffold (
sheetContent: @Composable ColumnScope. () -> Unit,
modifier: Modifier =Modifier,
scaffoldState: BottomSheetScaffoldState =rememberBottomSheetScaffoldState (),
sheetPeekHeight: Dp =BottomSheetDefaults. SheetPeekHeight,
sheetMaxWidth: Dp =BottomSheetDefaults. SheetMaxWidth,
sheetShape: Shape =BottomSheetDefaults. ExpandedShape,
sheetContainerColor: Color =BottomSheetDefaults. ContainerColor,
sheetContentColor: Color =contentColorFor (sheetContainerColor),
sheetTonalElevation: Dp =BottomSheetDefaults. Elevation,
sheetShadowElevation: Dp =BottomSheetDefaults. Elevation,
sheetDragHandle: (@Composable () -> Unit)? = { BottomSheetDefaults. DragHandle () },
sheetSwipeEnabled: Boolean =true,
topBar: (@Composable () -> Unit)? = null,
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost (it) },
containerColor: Color =MaterialTheme. colorScheme. surface,
contentColor: Color =contentColorFor (containerColor),
content: @Composable (PaddingValues) -> Unit
): Unit
参数解释 :
参数 | |
---|---|
sheetContent: @Composable ColumnScope. () -> Unit | BottomSheetScaffold内容 |
modifier: Modifier =Modifier | 用于BottomSheetScaffold的Modifier |
scaffoldState: BottomSheetScaffoldState =rememberBottomSheetScaffoldState () | BottomSheetScaffold的状态 |
sheetPeekHeight: Dp =BottomSheetDefaults. SheetPeekHeight | 折叠时的高度 |
sheetMaxWidth: Dp =BottomSheetDefaults. SheetMaxWidth | 定义了将采用最大宽度,传入跨整个屏幕的工作表 |
sheetShape: Shape =BottomSheetDefaults. ExpandedShape | BottomSheetScaffold的形状 |
sheetContainerColor: Color =BottomSheetDefaults. ContainerColor | BottomSheetScaffold的背景色 |
sheetContentColor: Color =contentColorFor (sheetContainerColor) | BottomSheetScaffold提供给其子项的首选内容颜色。默认为 的匹配内容颜色,或者如果这不是主题中的颜色,则将保留在底部工作表上方设置的相同内容颜色。 |
sheetTonalElevation: Dp =BottomSheetDefaults. Elevation | 色调提升 |
sheetShadowElevation: Dp =BottomSheetDefaults. Elevation | 阴影 |
sheetDragHandle: (@Composable () -> Unit)? = { BottomSheetDefaults. DragHandle () } | 用于拉动BottomSheetScaffold的视觉标记 |
sheetSwipeEnabled: Boolean =true | BottomSheetScaffold的滑动是否启用,是否应对用户的输入做出反应 |
topBar: (@Composable () -> Unit)? = null | 屏幕的顶部应用栏,通常使用SmallTopAppBar |
snackbarHost: @Composable (SnackbarHostState) -> Unit = { SnackbarHost (it) } | 组件到主机,这些组件被推送显示。 |
containerColor: Color =MaterialTheme. colorScheme. surface | BottomSheetScaffold背景颜色 |
contentColor: Color =contentColorFor (containerColor) | 内容首选颜色,默认为匹配内容颜色,如果不是主题中的颜色,则默认为当前颜色。 |
content: @Composable (PaddingValues) -> Unit | 屏幕的内容。lambda 接收应通过 Modifier.padding 和 Modifier.consumeWindowInsets 应用于内容根目录,以正确偏移顶部和底部栏。如果使用 Modifier.verticalScroll,请将此修饰符应用于滚动的子项,而不是滚动本身。 |