Arjun sharma Arjun sharma - 2 months ago 209
Android Question

Android Tablayout tabs with notification badge like whatsApp

I want to implement notification badge with

android.support.design.widget.TabLayout
. I had tried my best effort to implement it but fails.

Any help would by greatly appreciated.

Answer

My solution to this was using https://github.com/jgilfelt/android-viewbadger and setting a custom view to each tab:

My tabs have only icons so I used ImageView, but I believe you can use any other view, check https://github.com/jgilfelt/android-viewbadger/blob/master/README.markdown:

private BadgeView badge;

Tab tab = tabLayout.getTabAt(position);
ImageView imageView = new ImageView(context);
tab.setCustomView(imageView);
badge = new BadgeView(context, imageView);