Android 14 predictive back background color mismatch

480 views Asked by At

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).

2

There are 2 answers

0
SweSnow On BEST ANSWER

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.

2
Zain On

I get correct dark/light predictive backdrop but I want to fully match the window background as in the settings app).

The predictive back light/dark colors are system wide colors that are determined when the user changes the theme of their device.

The predictive back color looks like the same in both shared screenshots of the Settings app and your own app, that's because it's a sole color for the current theme/darkness mode picked by the user.

However, in the Settings app, the predictive back color looks coherent with the app's background color because the Settings app is a System app that is entirely styled with the system-wide colors (which are coherent by default).

The user can pick their preferred theme from the device settings, On Google Pixel 7 Pro: Settings > Wallpaper & style > System colors

enter image description here

So, as of writing this answer, unfortunately the predictive back color is not a something that can be controlled by developers, but users.