I have defined a base style for my application with the following element:
- @color/window_background
How about setting both windowBackground
and colorBackground
<item name="android:windowBackground">@color/window_background</item>
<item name="android:colorBackground">@color/window_background</item>
I used to have a same problem, but I found out by trying that if I commented actionBarTheme
in my styles, it started to work suddenly. I dug deeper in my styles and found out that the style of action bar was setting a android:background
attribute after commenting it out everything works now as expected.
I haven't found anything specific for Marshmallow that would cause this. So the suggestions I have are:
Changing the background color resource to a drawable shape resource.
From:
<item name="android:windowBackground">@color/window_background</item>
To:
<item name="android:windowBackground">@drawable/window_background</item>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="@color/window_background"/>
</shape>
In case you haven't checked the opacity of all your views:
Make sure your windowBackground actually is the background of most of your Activity (particularly over scrollable sections where overdraw is the most important to avoid), removing opaque view backgrounds where possible.
Make your windowBackground work for you instead of using null
I thought this was interesting, to see the precedence of how background layers are set. I am not sure if you are setting any view backgrounds or how you have set up your app, but this is worth a read.
Backgrounds consist of several layers, from back to front:
- the background Drawable of the theme
- a solid color (set via setColor(int))
- two Drawables, previous and current (set via setBitmap(Bitmap) or setDrawable(Drawable)), which may be in transition
BackgroundManager
I can't find if there is a difference with the themes in Marshmallow, or the order of elements, it seems there has been no fundamental changes and I can find no bug for this.
I hope this helps, let me know and I can have another look.
If this doesn't help it may be worth posting some more code relevant to the problem. Cheers.
If you're using Android Studio 1.4 or higher go to styles where your theme is located and click "Open Editor" in the upper right hand corner. Then change your window background there. It should be under "android:colorBackground"