Android Bottom Navigation View Multicolor Icon

I have a bottom navigation view with 4 icons, one of which is a notification icon. I have to notify when new notifications appear, I do this by changing the icon programmatically toIcon

Runtime problem: red dot is also gray. At startup Icons are set to gray by default, and when selected, it takes the main color of the application (unless the icon color is set). If I set the IconTint color to red then the entire image is red instead of a red dot. I want to show the image as it is and not have a background 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);
        }
    });

      

thank

R

+3


source to share


1 answer


You can achieve this with the following:

put 2 images in drawable folder, one with red dot with gray



and then in case the conditions you can set will show (R.drawable.yourimagename)

+1


source







All Articles