question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TabLayout] setHeight(or setSize) for TabItem's BadgeDrawable ?

See original GitHub issue

Hello

How can I set height(or size) for BadgeDrawable in TabLayout ?

        TabLayoutMediator(view.tabLayout, view.viewPager, TabLayoutMediator.TabConfigurationStrategy { tab, position ->
            tab.orCreateBadge.apply {
                backgroundColor = Color.parseColor("#db635d")
                horizontalOffset = -10
            }
            tab.text = when (position) {
                0 -> "주문 내역"
                1 -> "받은 선물"
                else -> null
            }
        }).attach()

expected

Screen Shot 2019-11-28 at 12 02 05 PM

but I’ve got

Screenshot_2019-11-28-14-22-47

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Kxtremecommented, Sep 18, 2020

I don’t know if I came on time but I found a simple patch to make it bigger, the idea is attach it and then clear its number I tested with 1.3.0:alpha02 here is a kotlin example:

    private fun addBadgeNotificationToView(
        v: View,
        parent: FrameLayout,
        verticalOffset: Int = 0,
        horizontalOffset: Int = 0): BadgeDrawable {
        val badge = BadgeDrawable.create(this);
        v.viewTreeObserver.addOnGlobalLayoutListener(object: ViewTreeObserver.OnGlobalLayoutListener {
            @Override
            override fun onGlobalLayout() {

                badge.verticalOffset = verticalOffset;
                badge.horizontalOffset = horizontalOffset;
                badge.number = 0

                BadgeUtils.attachBadgeDrawable(
                    badge,
                    v,
                   parent
                );
                badge.clearNumber()
                v.viewTreeObserver.removeOnGlobalLayoutListener(this);
            }
        })

        return badge
    }
0reactions
JorgeMucientescommented, Mar 28, 2022

Hey @wcshi! Friendly ping. Can we close this issue now?

Read more comments on GitHub >

github_iconTop Results From Across the Web

BadgeDrawable - Android Developers
BadgeDrawable contains all the layout and draw logic for a badge. ... Returns the height at which the badge would like to be...
Read more >
Android Tablayout tabs with notification badge like whatsApp
With the newest release of the Material Components , the Android team now offers an official BadgeDrawable to be used on the TabLayout...
Read more >
Notification BadgeDrawable + viewpager2 with tablayout ...
Need Help or Code Support? Feel Free To Contact Us Here http://www.aaviskar.com/support.phpThis videos shows implementation of Notification ...
Read more >
Android Tab Layout + Badge Drawable + View Pager 2
Android Tab Layout + Badge Drawable + View Pager 2 | Material Design Components | Android StudioIn this tutorial we will create a...
Read more >
log: com.newsblur:204 - F-Droid Monitor
BadgeDrawable $1 com.google.android.material.badge. ... TabLayout$SlidingTabIndicator$2 com.google.android.material.tabs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found