Suppresses the status bar and collapses top status bar inset padding to 0.dp.
ComponentSuppressStatusBarSample
@Sampled
@Composable
fun ComponentSuppressStatusBarSample() {
// Suppress the status bar to avoid overlapping with the full-screen circular progress
// indicator.
Box(
modifier =
Modifier.suppressStatusBar()
.background(MaterialTheme.colorScheme.background)
.padding(CircularProgressIndicatorDefaults.FullScreenPadding)
.fillMaxSize()
) {
CircularProgressIndicator(progress = { 0.75f }, startAngle = 120f, endAngle = 60f)
}
}
ScreenScaffoldSuppressStatusBarSample
@Sampled
@Composable
fun ScreenScaffoldSuppressStatusBarSample() {
// Suppress the status bar for a screen and collapse its insets to 0.dp.
ScreenScaffold(modifier = Modifier.suppressStatusBar()) { contentPadding ->
Box(
modifier =
Modifier.background(MaterialTheme.colorScheme.background)
.fillMaxSize()
.padding(contentPadding)
.padding(CircularProgressIndicatorDefaults.FullScreenPadding)
) {
CircularProgressIndicator(progress = { 0.75f }, startAngle = 120f, endAngle = 60f)
}
}
}
AppScaffoldSuppressStatusBarSample
@Sampled
@Composable
fun AppScaffoldSuppressStatusBarSample() {
// Suppress the status bar for the entire application and collapse insets on all child screens.
// Note: App-level suppression is not recommended for most apps because users will lose access
// to the time and important status indicators on every screen.
AppScaffold(modifier = Modifier.suppressStatusBar()) {
ScreenScaffold { contentPadding ->
Box(
modifier =
Modifier.background(MaterialTheme.colorScheme.background)
.fillMaxSize()
.padding(contentPadding),
contentAlignment = Alignment.Center,
) {
Text("App-level suppression")
}
}
}
}