@@ -87,9 +87,6 @@ public BottomNavigationItemView(@NonNull Context context, AttributeSet attrs) {
8787 public BottomNavigationItemView (Context context , AttributeSet attrs , int defStyleAttr ) {
8888 super (context , attrs , defStyleAttr );
8989 final Resources res = getResources ();
90- // Avoid clipping a badge if it's displayed.
91- setClipChildren (false );
92- setClipToPadding (false );
9390
9491 LayoutInflater .from (context ).inflate (R .layout .design_bottom_navigation_item , this , true );
9592 setBackgroundResource (R .drawable .design_bottom_navigation_item_background );
@@ -432,6 +429,10 @@ private void tryAttachBadgeToAnchor(View anchorView) {
432429 return ;
433430 }
434431 if (anchorView != null ) {
432+ // Avoid clipping a badge if it's displayed.
433+ setClipChildren (false );
434+ setClipToPadding (false );
435+
435436 BadgeUtils .attachBadgeDrawable (
436437 badgeDrawable , anchorView , getCustomParentForBadge (anchorView ));
437438 }
@@ -442,6 +443,10 @@ private void tryRemoveBadgeFromAnchor(View anchorView) {
442443 return ;
443444 }
444445 if (anchorView != null ) {
446+ // Clip children / view to padding when no badge is displayed.
447+ setClipChildren (true );
448+ setClipToPadding (true );
449+
445450 BadgeUtils .detachBadgeDrawable (
446451 badgeDrawable , anchorView , getCustomParentForBadge (anchorView ));
447452 }
0 commit comments