I have notification with custom RemoteView. I can change text color, depend on notification background color. But my black button still invisible on api<21, when background black too. Is there any way to fix this without changing background?
Asked
Active
Viewed 209 times
0

Gogi Bobina
- 1,086
- 1
- 8
- 25
-
how u set bg color – SWAPDROiD Oct 04 '17 at 13:49
-
@SwapnilNandapure i meen default notification background color. It black on android < 5.0 and white on android >= 5.0. Furthermore some os can override this color – Gogi Bobina Oct 04 '17 at 14:00
-
Okay u mean that u want to change background color of popup notification is it. – SWAPDROiD Oct 04 '17 at 14:02
2 Answers
0
You can try to use below code to set background color to your Remote View Notification.
NotificationCompat.Builder nBuilder = new NotificationCompat.Builder(this);
nBuilder.setSmallIcon(R.drawable.not_icon)
.setContentTitle(getCurrentSong().getTitle())
.setContentIntent(notOpenOnClick);
// This is what sets the background color on <N devices
// It is an accent color on N+ devices
nBuilder.setColor(getResources().getColor(R.color.colorPrimary));
// Add actions via nBuilder.addAction()
// Set the style, setShowActionsInCompactView(0) means the first
// action you've added will be shown the non-expanded view
nBuilder.setStyle(new NotificationCompat.MediaStyle()
.setShowActionsInCompactView(0));

SWAPDROiD
- 357
- 3
- 15
-
-
Ohh see previous lollipop u can use any image but from lollipop and above u want to use vector icon like transparent background and ur icon in white color. Like : https://image.flaticon.com/sprites/new_packs/126466-multimedia-collection.png get one of them and use it. – SWAPDROiD Oct 05 '17 at 04:49
0
After research, i use black icons for api>=21, and white icons with black stroke for api < 21.

Gogi Bobina
- 1,086
- 1
- 8
- 25