0
votes

I have a problem. In day theme i have a light status bar background and dark text, but if i change theme to night, the status bar background becomes dark and text becomes dark, but i need the text to become light. How can i do this?

Screenshots below:

light

dark

v23\themes code:

<style name="Theme.Light" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name="colorPrimary">@color/purple_500</item>
    <item name="colorPrimaryVariant">@color/action_bar</item> // this color looks like background
    <item name="colorOnPrimary">@color/white</item>

    <item name="colorPrimaryDark">@color/black</item>
    <item name="colorSecondary">@color/teal_200</item>
    <item name="colorSecondaryVariant">@color/teal_700</item>
    <item name="colorOnSecondary">@color/black</item>

    <item name="android:windowLightStatusBar">true</item>
    <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
</style>

night-v23\themes code:

<style name="Theme.Night" parent="Theme.AppCompat.DayNight.NoActionBar">
    <item name="colorPrimary">@color/purple_200</item>
    <item name="colorPrimaryVariant">@color/action_bar</item> // this color looks like background
    <item name="colorOnPrimary">@color/white</item>

    <item name="colorPrimaryDark">@color/white</item>
    <item name="colorSecondary">@color/teal_200</item>
    <item name="colorSecondaryVariant">@color/teal_200</item>
    <item name="colorOnSecondary">@color/white</item>

    <item name="android:windowLightStatusBar">false</item>
    <item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
</style>
1
I've tested your updates Code and it seems to work on my side. You'r not over ruling something somewhere else? - J Quest

1 Answers

1
votes

In your Android Project you can change those values inside your themes.xml, there should be two of them, One for Day Theme and one for Night Theme.

In those files you can change al the default colors that Android wil use.

You can find the themes.xml inside 'app' > 'res' > 'values' > 'themes.xml'

For more info is there also this use full answer; https://imstudio.medium.com/android-change-status-bar-text-color-659680fce49b

enter image description here

enter image description here