I would like to show count badge in front of Floating Action Button in android. I used FrameLayout in order to achieve that. My code is here
Give it a Try :
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
app:layout_anchor="@+id/containerpager"
app:layout_anchorGravity="bottom|right">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="@dimen/fab_margin"
android:elevation="0dp"
android:visibility="visible"
app:backgroundTint="@color/colorPrimary"
app:borderWidth="0dp"
app:fabSize="normal"
app:srcCompat="@drawable/ic_review_order" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="5"
android:textColor="@color/white"
android:textSize="22sp"
android:visibility="visible" />
</RelativeLayout>
you might wanna try this
<FrameLayout
android:layout_gravity="bottom|end"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.nex3z.notificationbadge.NotificationBadge
android:id="@+id/badge"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_gravity="right|top"
android:elevation="7dp"
app:nbMaxTextLength="2" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="15dp"
android:src="@drawable/ic_shopping_cart_black_24dp"
app:backgroundTint="@color/colorprice" />
</FrameLayout>