No matter what I try within themes I cant seem to change the colour of the status bar from this grey colour:
Here is my themes file:
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.AlarmClockProject" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/teal_200</item>
<item name="colorPrimaryVariant">@color/white</item>
<item name="colorOnPrimary">@color/black</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_700</item>
<item name="colorOnSecondary">@color/black</item>
<!-- Status bar color. -->
<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">#FF000000</item>
<!-- Customize your theme here. -->
<item name="windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>
I have tried multiple variations of this, removing some of these etc..
I have tried changing the colorPrimary/variant
etc to no avail.
I found this answer here that says to use the values-v23/styles.xml
but this seems outdated as I have no styles.xml
, now it is themes and this line is included above anyway.
target/compileSDK is 32, minSDK is 23
2
Answers
Add your custom color to
themes.xml
and also don’t forget to add in thenightthemes.xml
file. Otherwise, your status bar color shows the default color inDarkMode
.path-1:- res>values>themes>
themes.xml
path-2:- res>values>themes>
nightthemes.xml
add your custom color to
primaryVariant
and then add the below line in your colors.xml
path:- res>values>
colors.xml
here this code is
#888888
for gray. You can add your custom color code here.EDIT-1
set
Statusbar
colorProgrammatically
Add the below code to your
activity
inside theonCreate
method.I hope it helps.