Seems like you don't define the correct theme color. But check the below solution:
Kt.
val mode = if ((resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
Configuration.UI_MODE_NIGHT_NO
) {
AppCompatDelegate.MODE_NIGHT_YES
} else {
AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY
}
AppCompatDelegate.setDefaultNightMode(mode)
Colors.xml
Create a separate color file having root /values-night/color.xml
and define all those colors that u already defined in /values/color.xml
with your new night-theme-color codes.
Themes.xml
In /values/themes.xml
define your style:
<style name="Theme.VehicleApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_700</item>
<item name="colorPrimaryVariant">@color/purple_700</item>
<item name="colorOnPrimary">@color/white</item>
<!-- All your theme stuff -->
</style>
and in your /values-night/themes.xml
define only those style that you want to look change in night mode otherwise don't define the same style fields that u already defined in values/themes.xml, the rest of the color manipulation work will be done by color file itself :
<style name="Theme.VehicleApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<!-- Customize your theme here. -->
</style>