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 wou
This is an old cuestion, but Its much more simple these days. Im using Kotlin, AndroidX, using the next widget as TabLayout:
com.google.android.material.tabs.TabLayout
and inside my gradel app file:
implementation 'com.google.android.material:material:1.1.0-alpha09'
For setting a simple badge, just write..
yourTabLayout?.getTabAt(currentTabPosition)?.apply{
orCreateBadge
badge?.isVisible = true
}
Then just set isVisible = false to hide, like this:
private fun changeYourTabMethod(newTabPosition : Int) {
// do some stuff and then hide the badge...
yourTabLayout?.getTabAt(newTabPosition)?.apply{
badge?.isVisible = false
}
}