Open zishanj opened 5 years ago
yes,you can, but we should understand badge need bind to a view .So you may do like following
TabLayout.Tab tab = tabLayout.getTabAt(i);
View customView=inflater.inflate();//inflate your custom view
BadgeView badgeView=BadgeFactory.create(getActivity())
.setBadgeCount("1")
.setShape(BadgeView.SHAPE_CIRCLE)
.setWidth(16)
.setHeight(16)
.setSpace(6, 6)
.setTextColor(Color.WHITE)
.setBadgeBackground(ContextCompat.getColor(getContext(), R.color.pastel_red))
.setTextSize(11)
.bind(customView);
tab.setCustomView(customView);
Can the width and height be adjusted automatically based on the count value? If the counter value is bigger it should auto adjust its width.
I have tried your code but it does not attach to the view and does not show. No error reported though!
Can I bind to text or icon in
TabLayout
?