0

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?

Gogi Bobina
  • 1,086
  • 1
  • 8
  • 25

2 Answers2

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
  • thank you, but i not want change background, i want change icon – Gogi Bobina Oct 04 '17 at 14:41
  • 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