I'm having trouble getting BadgeDrawable to work.
There is no problem using it with BottomNavigationView
navView.setupWithNavController(navController)
val badge = navView.getOrCreateBadge(R.id.navigation_home)
badge.number = 12
But when I want to use it on other elements it wont show up. Like this:
val badgeDrawable = BadgeDrawable.create(context!!)
badgeDrawable.number = 32
BadgeUtils.attachBadgeDrawable(badgeDrawable, textView, root.findViewById(R.id.frame_layout))
I'm using the FrameLayout only because this issue fix seems to be not shipped yet.
Layout:
<FrameLayout
android:id="@+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/text_home"
android:src="@drawable/ic_home_black_24dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAlignment="center"
android:textSize="20sp" />
</FrameLayout>
I'm using the latest possible library version: 'com.google.android.material:material:1.2.0-rc01'
I've tried different methods. No luck though. Is there a secret to it which I'm missing?
Here is a git repo with the project (as simple as possible): https://github.com/marcinkunert/badgeissue