Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind to TabLayout #14

Open
zishanj opened this issue Dec 17, 2018 · 3 comments
Open

Bind to TabLayout #14

zishanj opened this issue Dec 17, 2018 · 3 comments

Comments

@zishanj
Copy link

zishanj commented Dec 17, 2018

Can I bind to text or icon in TabLayout?

@AlexLiuSheng
Copy link
Owner

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);

@zishanj
Copy link
Author

zishanj commented Dec 18, 2018

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.

@zishanj
Copy link
Author

zishanj commented Dec 18, 2018

I have tried your code but it does not attach to the view and does not show. No error reported though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants