My app is using a custom Notification layout with RemoteViews.
To display text, the layout is using the following system styles:
android:TextAppearance.Material.Notification.Title
android:TextAppearance.Material.Notification
This works fine.
However, the TextAppearance style can't be used to set the value of android:tint
, so I had to hardcode the color.
To my best knowledge, there's no special system style for setting notification ImageButton tint.
Hardcoded colors work fine on the current Android 5+ systems, but some users install custom ROMs with custom dark themes, and the notification looks wrong, i.e. black icons on black background.
Is there any way to get the system notification icon / imagebutton color, and apply it from an XML layout?
Or maybe there's another way to achieve this?
android.widget.RemoteViews. A class that describes a view hierarchy that can be displayed in another process. The hierarchy is inflated from a layout resource file, and this class provides some basic operations for modifying the content of the inflated hierarchy.
Custom Notifications option lets you select tones, vibration length, light, popup notifications, call ringtone, among others.
Sorry, But as per my knowledge custom ROM's have separate system designs,configurations and that are not official as well.
So,supporting Custom ROM without knowledge about its design is not possible. And android APIs are for supporting official ROM's.
Hope it Helps!!
Try this example :
Definition for notification :
// Declare variable
public static Bitmap icon;
// Assign value but this line can be different depends on current
// android sdk vesion ...
icon = BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.YOUR_IMAGE);
mBuilder = new NotificationCompat.Builder(this);
mBuilder.setShowWhen(false);
mBuilder.setDefaults(Notification.DEFAULT_ALL);
mBuilder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC);
mBuilder.setSmallIcon(R.drawable.image1); // One way to load img
mBuilder.setContentText("this text not visible");
mBuilder.setLargeIcon(icon);// This is the line
mBuilder.setPriority(Notification.PRIORITY_DEFAULT);
mBuilder.setContent(contentNotifySmall); // ORI
//mBuilder.setAutoCancel(false);
mBuilder.setCustomBigContentView(contentNotify);
I setup small and big variant for any case , this is important.
for background can you try these attributes...
app:backgroundTint="@color/pay"
---------Or-------------
android:tint="@color/white"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With