I have three activities on my App. MainActivity's layout is a DrawerLayout with fitsSystemWindows="true"
. The other two activities' root element is a CoordinatorLayout with the same properties. I've defined android:launchMode="singleTop"
for all activities in the manifest.
All activities use the same theme AppTheme
, which has the following attributes:
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowBackground">@color/background</item>
<item name="android:colorBackground">@color/background</item>
</style>
This works for the MainActivity, but does not for the other two, where the statusbar is black (instead of transparent as it should be). This was not the case with the previous version (v7:27.0.2) of the support library. Anyone have any idea what might be wrong here? Thanks in advance!
I have the same problem, with a slight twist: my status bar is completely white rather than black.
I had "solved" this problem by sticking with support-v27.0.2
when I first tried to upgraded to support-v27.1.0
. However, support-v27.1.1
is now released and the problem persists, so this is not likely to be a bug by google, and therefore needs a proper fix.
The solution that works for me is exactly as described by Thomas Vos in the comments below the OP. I thought it would be worth giving further detail here, as this appears to be the best solution.
In "styles.xml (v21)" you will likely have a style called "AppTheme.NoActionBar" which will look something like this:
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
You obviously may have additional items if you have edited the style, but whatever you have, just add the following to the bottom of the list between the style tags.
The status bar should then be back to normal.
<item name="statusBarBackground">?attr/colorPrimaryDark</item>
I "solved" this by downgrading to support-v27.0.2
. This is unfortunately one of those (not-so-rare) cases where Google changes something and doesn't document it anywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With