Pablo
03/10/2025, 11:02 PMModifier.safeDrawingPadding()
It is explained here. "_this ensures that interactable elements don't overlap with the system UI, it also means that none of the app will draw behind the system UI to achieve an edge-to-edge effect_".
The issue is that it leaves white spaces top and bottom of the screen even in Dark Mode. I checked other apps of the OS like chrome, and these spaces are dark, not white. I can't find anywhere why this happens and how to solve it. Supposedly this is the correct function to add the minimum required padding to avoiding overlapping with top or bottom OS bars.Stylianos Gakis
03/10/2025, 11:51 PMPablo
03/11/2025, 7:22 AMPablo
03/11/2025, 7:22 AMPablo
03/11/2025, 7:22 AMPablo
03/11/2025, 7:23 AMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
AppTheme {
App(modifier = Modifier.safeDrawingPadding())
}
}
}
}
Stylianos Gakis
03/11/2025, 7:52 AMPablo
03/11/2025, 9:01 AMPablo
03/11/2025, 9:06 AMAppTheme {
Box(modifier = Modifier.safeDrawingPadding().fillMaxSize().background(Color.Black))
}
In dark theme, the padding up and bottom is whitePablo
03/11/2025, 9:08 AMStylianos Gakis
03/11/2025, 9:11 AMPablo
03/11/2025, 9:21 AMPablo
03/11/2025, 9:21 AMPablo
03/11/2025, 9:21 AMPablo
03/11/2025, 9:21 AMPablo
03/11/2025, 9:22 AMPablo
03/11/2025, 9:22 AMStylianos Gakis
03/11/2025, 9:39 AMBox(modifier = Modifier.safeDrawingPadding().fillMaxSize().background(Color.Black))
Do this instead
Box(modifier = Modifier.fillMaxSize().background(Color.Black).safeDrawingPadding())
Stylianos Gakis
03/11/2025, 9:40 AMsupposedly the colors are already being applied before the padding
Why do you think that?
Stylianos Gakis
03/11/2025, 9:41 AMsetContent {
AppTheme {
}
}
Do you expect it to paint black in dark mode and white in light mode?Pablo
03/11/2025, 9:48 AMPablo
03/11/2025, 9:48 AMPablo
03/11/2025, 9:48 AMPablo
03/11/2025, 9:48 AMPablo
03/11/2025, 9:49 AM.safeDrawingPadding()
after setting the colors if I'm not setting the colors anywhere?Pablo
03/11/2025, 9:49 AMPablo
03/11/2025, 9:51 AM.background(Color.Black).safeDrawingPadding()
the padding is black on that sample, but how can I do that with my real app if I'm not specifying colors anywhere?Pablo
03/11/2025, 9:51 AMBox(modifier = modifier.fillMaxSize()) {
NavigationSuiteScaffold(
Pablo
03/11/2025, 9:54 AMBox(modifier = modifier.fillMaxSize().safeDrawingPadding()) {
NavigationSuiteScaffold(
Stylianos Gakis
03/11/2025, 11:07 AMI'm not doing .background anywhere
Do you have any surface anywhere in your app?
Pablo
03/11/2025, 11:51 AMStylianos Gakis
03/11/2025, 11:57 AMPablo
03/11/2025, 12:11 PMPablo
03/11/2025, 12:11 PMPablo
03/11/2025, 12:12 PMPablo
03/11/2025, 12:12 PMPablo
03/11/2025, 12:14 PMStylianos Gakis
03/11/2025, 1:04 PMUiModeManager#setApplicationNightMode
correctly the splash screen should also reflect the choiceStylianos Gakis
03/11/2025, 1:05 PMhow did you manage to find that solution?Well, if the color is inseted by the modifier you put in there, it's quite straightforward I'd say to imagine that you just need the color to be set before that inset.
Stylianos Gakis
03/11/2025, 1:07 PMPablo
03/11/2025, 6:22 PMPablo
03/11/2025, 6:22 PMPablo
03/11/2025, 6:23 PMPablo
03/11/2025, 6:23 PMPablo
03/11/2025, 6:23 PMPablo
03/11/2025, 6:25 PM@Composable
fun AppTheme(
darkTheme: Boolean = isSystemInDarkTheme(),
content: @Composable() () -> Unit,
) {
val colorScheme = when {
darkTheme -> darkColorScheme
else -> lightColorScheme
}
MaterialTheme(
colorScheme = colorScheme,
content = content,
)
}
Pablo
03/11/2025, 6:25 PMUiModeManager#setApplicationNightMode
anywhere because I'm not allowing user to customize itStylianos Gakis
03/11/2025, 6:49 PMI'm not using Splash Api. My app is displaying the automated splash generated by the OS when app is starting.
Then I don't know