深色模式下奇怪的错误颜色文本撰写

Bar*_*fet 7 android android-jetpack-compose

嗨,我是新作曲家,我正在尝试调试这个奇怪的文本颜色错误

颜色应该是白色,它就像一种灰色的深色,一旦我将它们滚动到视线之外并滚动回到之前的位置,它似乎就会消失并设置白色。

很确定以前有人犯过这个错误,我错过了什么吗?为什么会出现这个错误?

编辑:只有当我的手机激活了黑暗模式时才会发生这种情况。如果我停用它并在 TodoTheme(...) 中设置 false/true ,一切都会按预期工作。

最简单的重现代码:

setContent {
    TodoTheme {
        TodoScreen()
    }
}

@Composable
fun TodoScreen(
) {
    val text = "This is a big text that will make color change and won't be very much visible for the user, why does this happen?"
    LazyColumn(){
        items(listOf(text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text,text)) { string ->
            Text(text = string, color = MaterialTheme.colors.onSurface)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

颜色是默认的颜色(我不认为这是颜色问题):

val LightThemeColors = lightColors(
    primary = Purple700,
    primaryVariant = Purple800,
    onPrimary = Color.White,
    secondary = Color.White,
    onSecondary = Color.Black,
    background = Color.White,
    onBackground = Color.Black,
    surface = Color.White,
    onSurface = Color.Black,
    error = Red800,
    onError = Color.White
)

val DarkThemeColors = darkColors(
    primary = Purple300,
    primaryVariant = Purple600,
    onPrimary = Color.Black,
    secondary = Color.Black,
    onSecondary = Color.White,
    background = Color.Black,
    onBackground = Color.White,
    surface = Color.Black,
    onSurface = Color.White,
    error = Red300,
    onError = Color.Black
)
Run Code Online (Sandbox Code Playgroud)

这是一个视频,您可以准确观看正在发生的事情。这是在 Redmi Note 8 Pro 上。 https://www.youtube.com/watch?v=MwVO62NXCQU

还有图像: 在此输入图像描述

Kar*_*tik 14

编辑:

<style name="AppTheme" parent="...">
    <!-- Customize your theme here. -->
    <item name="android:forceDarkAllowed" tools:targetApi="q">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

您可以在用于应用程序的主题中添加此行,即使启用了强制黑暗模式,它也不会覆盖黑暗模式下的应用程序

原答案如下

如果您使用的是红米/小米手机,并且仅在手机中启用深色模式时出现此问题,请转到“设置”->“显示”->“更多深色模式选项”,然后从应用程序列表中取消选中您的应用程序,看看它是否有效适当地

但我还没有找到默认情况下打开这个东西的解决方案。一旦我发现这个答案,我也会更新这个答案。

从设置中选择深色模式

选择更多深色模式选项

从各个应用程序列表中找到您的应用程序并关闭切换开关