To draw behind the system status bar in Jetpack Compose Dialog, you can use the SystemUiController
API.
Here is the process:
onCreate
method of your activity, create an instance of SystemUiController
.val systemUiController = rememberSystemUiController()
setStatusBarColor
method of SystemUiController
and pass it a transparent color.systemUiController.setStatusBarColor(Color.Transparent, darkIcons = true)
Modifier.statusBarsPadding()
modifier to add padding to your content to avoid overlapping with the system status bar.AlertDialog(
onDismissRequest = dismiss,
title = { Text(text = "Title") },
text = { Text(text = "Content") },
confirmButton = {
Button(
onClick = { /* Handle confirm button click */ },
modifier = Modifier.statusBarsPadding()
) {
Text("Confirm")
}
},
dismissButton = {
Button(
onClick = dismiss,
modifier = Modifier.statusBarsPadding()
) {
Text("Cancel")
}
},
)
By using Modifier.statusBarsPadding()
, Jetpack Compose automatically adds padding to your dialog content, ensuring that it is not obscured by the system status bar.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-04-06 11:00:00 +0000
Seen: 13 times
Last updated: Feb 04 '22
How can the boolean variables be represented over time using a bar graph?
What does the error "Bar 0; array size is too large, maximum size is 100000" mean?
What are the steps to create a fixed navigation bar using Tailwind CSS utility classes?
What are the steps to create a fixed right-hand side bar on a modal using tailwindcss?
What is the method for placing the Navigation bar at the top of the HTML page?
How does the "row" in Bootstrap 3.3.7 lead to the appearance of a horizontal scroll bar?
What is the method for altering the progress bar color in C# .NET 3.5?