Default notification background color - android

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.

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

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

Related

?attr/colorPrimary support version?

I am in a fairly serious predicament. I have built my entire app using ?attr/colorPrimary to pick the color for background shapes, as I have devised a way to dynamically change the theme and color. This works perfectly on 5.0, but on all 4.x devices, ?attr/colorPrimary crashes the app. Why does Android studio not alert developers to this incompatibility?
Is there a support version of ?attr/colorPrimary?
colorPrimary is already part of AppCompat as of version 21 and works back to API 7. Your problem is instead with your theming code.
I believe it was added after Android Lollipop - API 21.
At least this link shows that it was added between API 20 and 21:
https://developer.android.com/sdk/api_diff/21/changes/android.R.attr.html
attr/colorPrimary just point to colorPrimary defined in current theme.
I'm not sure how you implemented your theme.. But you can create your own attr... This option is good only if you support several themes.
If you have a single theme, I believe you can replace it by a color.
API 21:
Material design style
Notifications are drawn with dark text atop white (or very light)
backgrounds to match the new material design widgets. Make sure that
all your notifications look right with the new color scheme. If your
notifications look wrong, fix them:
Use setColor() to set an accent color in a circle behind your icon
image. Update or remove assets that involve color. The system ignores
all non-alpha channels in action icons and in the main notification
icon. You should assume that these icons will be alpha-only. The
system draws notification icons in white and action icons in dark
gray.
The problem is a glitch in Android code. See this, it is not the exact same but the reason is.
In case anyone out there has this problem, I want to explain my workaround.
Remove all instances of "?attr/color(Primary, Dark, or Accent)" and attempt to mimic the effect in each individual element in each individual activity. This is not a full work around, but for me it works. Google really needs to resolve this issue. If you know a better work around, please let me know and I will accept it as the better answer as long as it works.

android notification background color is not white on lollipop

As we known that Android lollipop force set the notification background color to white, so we can set the style of TextView according to different sdk version by putting style.xml in folder values-v21.
So here comes my question, on some third party ROMs, for example, the EMUI developed by Huawei tech co., the background of notification is not white(nearly black), by setting style to
android:TextAppearance.Material.Notification.Title
the color of the text is almost black, as a result, we cannot see the text clearly. I had been searching the internet for almost two days but find nothing helps.
I am trying to get the color of the notification background and set the text color dynamically, but I don't know how to accomplish this.
Need your help, thanks a lot.
Ok, so I just use the official API to set the notification info, that would inflate the default notification layout (status_bar_latest_event_content.xml)instead of my custom layout.
The rom changed the default background and text-color of the status_bar_latest_event_content.xml, but it wouldn't (or can't) change the custom layout.
mBuilder.setLargeIcon(combineBitmap).setContentText(notifyString).setSubText("fff");
remove the android:targetSdkVersion="21" from manifest.xml. it will work! and from this there is no prob at all in your apk it just a trick i apply this and i found colorful icon in notification and all features will remain same which u earlier use

What is the portable way to ensure certain attribute (android:attr/textAppearanceMedium for example) works across different version of Android

Currently, I'm using theme Theme.Sherlock.Light.DarkActionBar.
I'm applying ?android:attr/textAppearanceMedium and ?android:attr/textAppearanceSmall attributes, for the TextView used in ListView
<TextView
...
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
...
android:textAppearance="?android:attr/textAppearanceSmall" />
However, for Jelly Bean and Gingerbread, I get 2 very different effects.
Jelly Bean (Looks great!)
Gingerbread (Ergh...)
Is there any portable way I can tell, when using textAppearanceMedium and textAppearanceSmall attributes on a light background, the color should be dark. Currently, Gingerbread is using light background for its list view. Hence, the correct font color should be dark, so that text is visible.
I understand that you want to support the native look of the respective Android version and want to avoid overwriting default colors.
A "vanilla" Gingerbread version might look like the one in your screenshot, but I have also seen GUI adaptations of device manufacturers (such as Samsung TouchWiz or HTC Sense) or Custom ROMs overwriting these color values. Not only the default background colors, also text colors.
In consequence, you cannot be sure that all pre-Honeycomb versions show bright text on a white background in dropdowns, so you'd have to check the text color as well and adapt it accordingly. Checking background or foreground resources/colors of a view can be very cumbersome, but here are two approaches: https://stackoverflow.com/a/8089242/1140682 and https://stackoverflow.com/a/8848494/1140682
However, I highly suggest that you apply custom, "fixed" colors to your text and background. Since the ActionBar has only been introduced with Honeycomb, there are no ActionBar guidelines/styles for previous versions that you could violate anyway.
A good start for this is the ActionBar Style Generator that also supports Theme.Sherlock.Light.DarkActionBar. It generates all the drawables and style files for you so that your ActionBar and menus look consistent across multiple Android versions and modifications.

Changed button style after SDK 13

My new game app was originally designed for a targetSDK of 13. I've since bumped it up, but my default buttons have changed in appearance. Not on the emulator, but on my actual Galaxy S3 phone, running 4.0.4.
The old buttons were rectangular with a translucent background and white letters. The new buttons look the same, but have an opaque, dark gray background. It happens for any targetSDK greater than 13.
Any ideas why, and how I can fix it? I'm not applying any specific style to them.
It is happening because of googles new holo theme
The way to stop it from happening is to specifiy a theme in you manifest (right below the android:name and android:label attributes of your activity. Adding the following line will remove you
<application android:theme="#android:style/Theme">
This should remove the holo theme, if it doesn't you can play around with some other themes until you find one which works. This might help - http://developer.android.com/guide/topics/ui/themes.html

EditText not showing under Ice Cream Sandwich

I have a EditText in a layout with a white background.
On Android 2.x, the EditText is visible with a frame around it, but in Ice Cream Sandwich on a Galaxy Nexus, it is not visible until I click on it. Then the blue line under it appears.
I think this is due to the holo theme in Ice Cream Sandwich, but can I somehow get the line to show all the time? Or do I have to add a custom background 9patch-image?
I am using ActionBarSherlock for compatibility, but I don't think this is an issue here, as the EditText is shown normally on older Versions.
Regards,
Kim
I would recommend creating your own background for it. Another thing you can do is which may or may not work for your app's purpose is set that view to be focused by default.
Just have your view call requestFocus() after it's loaded.
If you add hint to the EditText then gray line should show up.
You can also create custom theme by overriding the Holo theme but why confuse people with platform's behavior is the question.

Categories

Resources