Search code examples
androidmaterial-components-androidpredictive-back

Android 14 predictive back background color mismatch


I am implementing predictive back in my android app and am facing a problem. In the left screenshot below, the redder color is my android:windowBackground and I am in the process of doing a predictive back. As you can see, around the red area in a darker color. What I want is for the the predictive back background color to blend in with the app background color as is done in e.g. the settings app, see the right image.

Current behavior Desired behavior

The theme I use inherits from Theme.Material3.Dark.NoActionBar, both activities inherit from AppCompatActivity and I use implementation 'com.google.android.material:material:1.11.0-alpha03'.

Meanwhile if I set the app to use a light theme, I get a white backdrop during predictive back which again does not agree with the set android:windowBackground.

In case anyone wants to have a deeper look at the specific code used in this example the app is open source at GitHub but I really do believe this to be a question of general interest and the previous Stack Overflow question is similar but does not seem to be the same (I get correct dark/light predictive backdrop but I want to fully match the window background as in the settings app).


Solution

  • After a lot of looking, I found out that this property is set by <item name="android:colorBackground">@color/my_background_color</item> in the app theme. Specifically, to get the same effect as in the settings app, one should set this values to the same as android:windowBackground.