Search code examples
androidmaterial-designandroid-tablayoutmaterial-componentsmaterial-components-android

Class BadgeDrawable not found. How to use material design BadgeDrawable in Android


For the first time, I am trying to use the badge notification icon on the material TabItem. My goal is to show the badge with the total number of items in the RecyclerView. I was going through with this document Tab Layout - Material Components for Android and trying to implement the functionality accordingly, but at this line BadgeDrawable badge = tablayout.getTab(0).getOrCreateBadge(); I am getting error that BadgeDrawable class not found.

Can anyone help me with this?

Thanks


Solution

  • Resolved by upgrading com.google.android.material:material version from 1.0.0 to 1.1.0-alpha10 in build.gradle(Module:app) file.

    dependencies {
    implementation 'com.google.android.material:material:1.1.0-alpha10'
    }