Making custom notifications match default style - android

I'm struggling with creating a custom notification whose expanded view is defined by a RemoteView using a bigContentView.
I'd like for this notification to look exactly like a default notification however I'm having issues achieving this across all platforms.
I can pull the font size and color of the title and description using #android:style/TextAppearance.StatusBar.EventContent.Title however I can't seem to find a way to determine what positioning to use for those titles and descriptions (margins, padding).
I also can't seem to determine what icon size or background to use for the icon. For example on some devices, there is a light blue background that appears behind the notification icon, but on Samsungs this doesn't seem to be the case.

Related

How to change the text colour of Android Notification

We are using Foreground Service with Notification. A very simple use-case requires us to change the text-colour of the notification's body and title text. After a quick search, I was enlighten with setColor() method of NotificationCompat.Builder.
However, using it only changes the tint colour of the small icon and not the notification title or body text. I also wanted the text 0/7 files have been uploaded and 7 pending to be coloured desirably. This is how it looks currently,
How can I change the text colour of the notification title and body text?
you can't change this, this is system style for Notification, don't have option for setting text color... but you can introduce your own layout for this purpose, but be aware that across different Android distributions there are different default Notification styles (made by manufacturers) and you won't provide one universal style with only-text-color-changed style, which will fit into system styling (same look as other notifications)

Android N notification title and icon color is darker

When showing a notification in android N and O it shows like this
You can change the top color of the icon and the app name by using setColor method of the NotificationCompat.Builder, The problem is that the displayed color doesn't match the provided one as it gets darker in the notification.
I tested it on Google Pixel(Oreo). Is this documented somewhere? Any workarounds?
Google decided to restrict acceptable colors in Notification when using setColor. Yes, it's undocumented, unsolicited and evil! After some digging (hacker's way) it may be found in the source code of (internal) ContrastColorUtil. Inspect line 300 (findContrastColor) and 475 (resolveContrastColor) where the rationale is:
Resolves a Notification's color such that it has enough contrast to be
used as the color for the Notification's action and header text.
I do not agree. Google should have known better and be doing no evil to the freedom of aesthetic choices of designers and developers.

Is there a template for Honeycomb-style custom notifications?

I'm trying to create a custom notification layout that looks just like a 3.0 notification, with a couple of extra things sprinkled in. More importantly, I also want to derive a Jelly Bean expanded notification on top of that.
I'd like the notification to have the same layout as a stock notification so it fits in nicely, i.e. like this (bottom image):
However, I cannot find any information about the proper dimensions and styles - what size do I need to use for the image on the left? What style for each text? What padding?
Ideally, I'd love to use something like android.R.listPreferredItemHeight for the height of the layout and the dimensions of the image, but I can't find anything that pertains to notifications.
You can use the Notification.Builder class which provides a convenient way to set the various fields of a Notification and generate content views using the platform's notification layout template.
See: http://developer.android.com/reference/android/app/Notification.Builder.html
If you need to be compatible with versions prior to API level 11 then take a look at the NotificationCompat.Builder from the support library.

Status bar colors and resources

I'm creating my own remote view for the status bar(notification center). I want the remote view to have the same background color as the other notifications and I want it to be consistent across devices, e.g. Samsung and stock Android.
The only layout information I managed to find was under \android-sdk\platforms\android-14\data\res\layout\status_bar_latest_event_content.xml
In addition I found icon guidelines however I couldn't find anything related to background color.
I played with Photoshop and found the default color for Stock Android (#111111), however I don't want to hard code it.
When not using any background color the default that I get is grayish (see attachment)
Any suggestions ?

Title of Android AppWidget below widget-icon

I am working on a small application which should be represented by an AppWidget.
The AppWidget should look like many other widgets on my HTC Desire. Most of them consist of an icon and a title below the icon. The title always looks identical, it is white text on a black rounded banner. I have not found a way to get this layout without painting all by myself. What do I have to do, to get the app title shown below the AppWidget?
Thank in advance,
Wolfgang
Per a previous answer here this is actually discouraged by the Android UI guidelines: An App shortcut has such text below it, and it may change in future Android releases or in custom skins such as HTC Sense or MOTOblur. A widget should be a wholly contained graphical element without a text label below it. You need to find a way to make graphics / text in your widget which are self identifying to the user.

Categories

Resources