4

I have tried tried a few solutions given here but none seems to work for me. This is what I have in my colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#fcfdfb</color>
    <color name="colorPrimaryDark">#fff</color>
    <color name="colorPrimaryLight">#333</color>
    <color name="colorPrimaryText">#333</color>
    <color name="colorAccent">#000000</color>
    <color name="white">#ffffff</color>
    <color name="black">#000000</color>
</resources>

And this is what I have in styles.xml

<resources xmlns:tools="http://schemas.android.com/tools">
    <style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@drawable/background_splash</item>
    <item name="android:windowActionBar">false</item>
</style>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@drawable/background_splash</item>
    <item name="android:windowActionBar">false</item>
</style>
<style name="ProDialogue" parent="@android:style/Theme.Dialog">
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@color/colorPrimary</item>
    <item name="android:textColor">@color/black</item>
</style>
<style name="TransparentToolbar" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
    <item name="android:windowActionBarOverlay">true</item>
    <item name="windowActionBarOverlay">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />

I just need the Statusbar text/icons to be black because I have the background as white to match the content. As a beginner, I am sure that I've messed it up somewhere but hopefully someone will guide me on this. Btw, my minSdkVersion is 21.

Zain
  • 37,492
  • 7
  • 60
  • 84
dspblack
  • 65
  • 1
  • 4

1 Answers1

6

Add these attributes to your theme

<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">@color/white</item>

Note this only works on 23+, so you'll have to make a 23+ theme file with these attributes. I'm fairly sure that < 23 every device's status bar is black and white and you can't change that, but you should double check

George
  • 485
  • 1
  • 5
  • 13
  • This worked for me after changing the minSdkVersion to 23. Thank you. – dspblack Jun 14 '21 at 07:33
  • @dspblack You don't have to change it to 23, you can create a second theme file in a values-v23 folder and use it in there. That way it works on 23 and below. I'm fairly certain the reason you can't change the status bar text color < 23 is because all devices use the standard black and white status bar at that version – George Jun 14 '21 at 14:26