How can we disable dark mode in compose?
# compose
m
How can we disable dark mode in compose?
c
Simply always set
lightColors()
to your
MaterialTheme
1
m
I tried that but it didn’t work.
c
Please post some code. BTW, are you sure your device not inverting the colors?
m
Copy code
private val LightColorPalette = lightColors(
    primary = Primary1,
    primaryVariant = Secondary1,
    onPrimary = Primary1,
    background = Secondary3,
    onBackground = Primary1,
    secondary = Blue05,
    onSecondary = Primary1
    /* Other default colors to override
    background = Color.White,
    surface = Color.White,
    onPrimary = Color.White,
    onSecondary = Color.Black,
    onBackground = Color.Black,
    onSurface = Color.Black,
    */
)

@Composable
fun DigibankTheme(
    darkTheme: Boolean = isSystemInDarkTheme(),
    content: @Composable() () -> Unit
) {

    MaterialTheme(
        colors = LightColorPalette,
        typography = Typography,
        shapes = Shapes,
        content = content
    )
}
a
You can disable forced dark mode by running this cmd
adb shell setprop debug.hwui.force_dark false
m
I want to disable it for my builds
a
You code is correct, if you are using MIUI then this issue happens. Either switch to light theme in your device or run this above command using adb
m
It doesn’t work for me even on an emulator
c
Are you wrapping every Composable with that theme that only passes light colors? There could be an issue with how you setting your theme that is affecting parts of your hierarchy. Screenshots and code snippets in context of UI would also help us debug together.