4

I have a bottom navigation view with 4 icons, one of them being a notification icon.I have to notify when there are new notifications, I am doing that by changing the icon programmatically to Icon

The problem is at runtime the red dot is also grey. At runtime The icons are by default set to grey and on selection it takes primary color of the app (incase no iconTint color is set). If I set the IconTint color to red then the whole image is red instead of just the red dot. I want to show the image as is and not have the background color effect on it. Is there a way to achieve this?

final Menu menu =bottomNavigationView.getMenu();
    Handler handler = new Handler(Looper.getMainLooper());
    handler.post(new Runnable() {
        @Override
        public void run() {
            MenuItem notificationItem=menu.findItem(R.id.action_notification);
            notificationItem.setIcon(R.drawable.notification_icon_with_badge);
        }
    });

Thanks

P

user2622786
  • 779
  • 3
  • 9
  • 21

1 Answers1

1

You can achieve this with the following also

place 2 images in the drawable folder, one with the red dot one with grey

and then on if conditions you can setimageresource(R.drawable.yourimagename)