最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - White splash screen with dark theme - Stack Overflow

programmeradmin4浏览0评论

Splash screen generated by OS doesn't paint in black when OS dark theme is enabled. Has anyone disscovered how to solve this? It should be dark, not white, like almost everything in dark theme.

To clarify, I'm not talking about a custom splash developed with Splash API, I'm talking about the default and automatic splash that the OS adds to your app. For some reason, is ignoring dark theme, and as it is generated and managed by the OS, it should be dark.

Is there any way to solve this?

This is my onCreate:

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            AppTheme {
                Surface(modifier = Modifier.fillMaxSize()) {
                    App(modifier = Modifier.safeDrawingPadding())
                }
            }
        }
    }

this is my AppTheme:

@Composable
fun AppTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable() () -> Unit,
) {
    val colorScheme = when {
        darkTheme -> darkColorScheme
        else -> lightColorScheme
    }

    MaterialTheme(
        colorScheme = colorScheme,
        content = content,
    )
}

Splash screen generated by OS doesn't paint in black when OS dark theme is enabled. Has anyone disscovered how to solve this? It should be dark, not white, like almost everything in dark theme.

To clarify, I'm not talking about a custom splash developed with Splash API, I'm talking about the default and automatic splash that the OS adds to your app. For some reason, is ignoring dark theme, and as it is generated and managed by the OS, it should be dark.

Is there any way to solve this?

This is my onCreate:

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContent {
            AppTheme {
                Surface(modifier = Modifier.fillMaxSize()) {
                    App(modifier = Modifier.safeDrawingPadding())
                }
            }
        }
    }

this is my AppTheme:

@Composable
fun AppTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable() () -> Unit,
) {
    val colorScheme = when {
        darkTheme -> darkColorScheme
        else -> lightColorScheme
    }

    MaterialTheme(
        colorScheme = colorScheme,
        content = content,
    )
}
Share Improve this question asked Mar 11 at 18:55 NullPointerExceptionNullPointerException 37.8k80 gold badges231 silver badges405 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I created a new theme.xml with "night" qualifier, and I wrote that app theme must extend from android:Theme.Material.NoActionBar instead of android:Theme.Material.Light.NoActionBar

and now it works perfectly

发布评论

评论列表(0)

  1. 暂无评论