ARTICLE AD BOX
I developed an app with transparent system bars and it is correctly appearing transparent on my Pixel 7 and all virtual devices across many Android versions (7.0, 9.0, 14.0, 15.0, 16.0), but on a Samsung Galaxy S23 Ultra (Android 14) of a friend, the system bar is black:
Screenshot from Samsung with Android 14 (black status bar)
Screenshot from virtual Android 14 (transparent status bar)
In other apps on his phone, the status bar is transparent. Did someone have the same issue or has experience to provide help? Do Samsung devices need some special treatment when it comes to status bars?
This is the relevant code snippets from my app:
SystemAppearance:
@Composable actual fun SystemAppearance(isDark: Boolean) { val view = LocalView.current val colorScheme = MaterialTheme.colorScheme if (!view.isInEditMode) { SideEffect { val window = (view.context as Activity).window WindowCompat.setDecorFitsSystemWindows(window, false) val controller = WindowCompat.getInsetsController(window, window.decorView) if (Build.VERSION.SDK_INT >= 28) { // >= Android 9 window.attributes.layoutInDisplayCutoutMode = android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES } @Suppress("DEPRECATION") if (Build.VERSION.SDK_INT >= 29) { // >= Android 10 window.statusBarColor = Color.Transparent.toArgb() window.navigationBarColor = Color.Transparent.toArgb() } else if (Build.VERSION.SDK_INT <= 25) { // <= Android 7 window.statusBarColor = colorScheme.primaryContainer.toArgb() window.navigationBarColor = colorScheme.primaryContainer.toArgb() } else { window.statusBarColor = colorScheme.primaryContainer.toArgb() window.navigationBarColor = Color.Transparent.toArgb() } if (Build.VERSION.SDK_INT >= 29) { // >= Android 10 window.isStatusBarContrastEnforced = false window.isNavigationBarContrastEnforced = false } } } }In MainActivity.kt:
enableEdgeToEdge( statusBarStyle = SystemBarStyle.dark( android.graphics.Color.TRANSPARENT ), navigationBarStyle = SystemBarStyle.light( android.graphics.Color.TRANSPARENT, android.graphics.Color.TRANSPARENT ) )In Theme.kt:
@Composable fun SongBookTheme( darkTheme: Boolean = isSystemInDarkTheme(), fontSize: Float = 16f, content: @Composable () -> Unit ) { val colorScheme = if (darkTheme) DarkColorScheme else LightColorScheme MaterialTheme( colorScheme = colorScheme, typography = getTypography(fontSize.sp) ) { SystemAppearance(darkTheme) content() } }The SongBookTheme is called in MainActivity after enableEdgeToEdge() inside the setContent block.
