Default notification background color
Asked Answered
C

2

5

I have a custom notification that uses a LinearLayout that contains an ImageView and a TextView. Before Android 4.0 all I needed to do was swap out the text colors with the EventContent and EventContent.Title styles and all the colors looked great.

But on Android 4.0 (Ice Cream Sandwich) my custom notification background color is a light gray, and to make matters worse it clashes horribly with the default text styles. This is strange to me, since all the other notifications have a dark-gray (almost black) color, and I haven't changed the background color at all in my layout.

Is there a way to access the default background color for notifications? I don't want to manually set this to black (or another color) since I want it to go well with the theme on the device. But I've looked around and can't find anything that gives me that color.

Carlist answered 28/12, 2011 at 18:43 Comment(0)
C
2

This appears to be a bug in Android 4.0.3. See bug report for updates: http://code.google.com/p/android/issues/detail?id=23863&thanks=23863&ts=1325611036

Carlist answered 3/1, 2012 at 19:18 Comment(1)
It is not a bug. Status is "WorkingAsIntended" according to code.google.com/p/android/issues/…Jeffiejeffrey
J
6

I also have a custom notification and found that the background color was also gray on ice cream sandwich. I see this with other apps too, like WeatherBug.

I had no targetSdkVersion in my manifest. I found that by adding targetSdkVersion="14" to the manifest the problem is fixed. The background is now the appropriate color for each android version.

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14" />

Edit: Google confirms this is the correct approach. See #16 at https://code.google.com/p/android/issues/detail?id=23863&thanks=23863&ts=1325611036

Jeffiejeffrey answered 27/4, 2012 at 17:57 Comment(5)
Thanks. This seems like a much better work-around than setting the background color. I'll give this a try and let you know.Carlist
This is a very neat solution but, changing target to v14 disables the menu.Lawannalawbreaker
Hi Kirill. What do you mean by disables the menu? What menu are you referring to?Jeffiejeffrey
@Jeffiejeffrey Kirill means activity menu compatibility mode (displayed as three dots to the right of the Recents button)Circumlunar
Actually, targetSdkVersion="9" is enough (see explanation at baroqueworksdev.blogspot.ru/2012/02/…)Circumlunar
C
2

This appears to be a bug in Android 4.0.3. See bug report for updates: http://code.google.com/p/android/issues/detail?id=23863&thanks=23863&ts=1325611036

Carlist answered 3/1, 2012 at 19:18 Comment(1)
It is not a bug. Status is "WorkingAsIntended" according to code.google.com/p/android/issues/…Jeffiejeffrey

© 2022 - 2024 — McMap. All rights reserved.