I am trying out AppCompat on Marshmallow. And I want to have a transparent status bar however it turns white. I\'ve tried a couple solutions but they didn\'t work for me (Tr
My guess is that this is caused by your android:windowBackground
. Is @color/background_material_light
a reference to white?
I faced the same issue. What i did was, in the "v21/styles.xml" file a changed the value true:
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
to:
<item name="android:windowDrawsSystemBarBackgrounds">false</item>
Just put this item in your v21\styles.xml :
true
It should look 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:windowTranslucentStatus">true</item>
</style>
If you are using RelativeLayout / CoordinatorLayout this is the solution that worked for me:
You have to use
Rember to use CoordinatorLayout instead of RelativeLayout (the performance is better and perfectly works with AppBarLayout)
This is how your fragment should starts
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/background_light"
android:fitsSystemWindows="true"
>
<android.support.design.widget.AppBarLayout
android:id="@+id/main.appbar"
android:layout_width="match_parent"
android:layout_height="300dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true"
>
...
Good coding!
For styles v23
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowLightStatusBar">true</item>
<item name="android:statusBarColor">@android:color/white</item>
</style>
For styles v21
<style name="MyTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowTranslucentStatus">true</item>
<item name="android:statusBarColor">@android:color/white</item>
</style>
Window window = this.getWindow();
window.setStatusBarColor(this.getResources().getColor(R.color.colorPrimaryDark));
Add this 2 line in java file below