@@ -20,27 +20,25 @@ navigate to.
2020
2121## Design & API Documentation
2222
23- - [ Material Design guidelines: Bottom
24- Navigation] ( https://material.io/go/design-bottom-navigation )
23+ - [ Material Design guidelines: Bottom Navigation] ( https://material.io/go/design-bottom-navigation )
2524 <!-- {: .icon-list-item.icon-list-item--spec }-->
26- - [ Class
27- definition] ( https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/bottomnavigation/BottomNavigationView.java )
25+ - [ Class definition] ( https://github.com/material-components/material-components-android/tree/master/lib/java/com/google/android/material/bottomnavigation/BottomNavigationView.java )
2826 <!-- {: .icon-list-item.icon-list-item--link }-->
2927 <!-- Styles for list items requiring icons instead of standard bullets. -->
30- - [ Class
31- overview] ( https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView )
28+ - [ Class overview] ( https://developer.android.com/reference/com/google/android/material/bottomnavigation/BottomNavigationView )
3229 <!-- {: .icon-list-item.icon-list-item--link }--> <!-- {: .icon-list }-->
3330
3431## Usage
3532
36- 1 . Create a [ menu
37- resource] ( https://developer.android.com/guide/topics/resources/menu-resource.html )
38- with up to 5 navigation targets (` BottomNavigationView ` does not support more than
39- 5 items).
40- 2 . Lay out your ` BottomNavigationView ` below your content.
41- 3 . Set the ` app:menu ` attribute on your ` BottomNavigationView ` to your menu
42- resource.
43- 4 . Listen for selection events using ` setOnNavigationItemSelectedListener(...) ` .
33+ 1 . Create a
34+ [ menu resource] ( https://developer.android.com/guide/topics/resources/menu-resource.html )
35+ with up to 5 navigation targets (` BottomNavigationView ` does not support
36+ more than 5 items).
37+ 2 . Lay out your ` BottomNavigationView ` below your content.
38+ 3 . Set the ` app:menu ` attribute on your ` BottomNavigationView ` to your menu
39+ resource.
40+ 4 . Listen for selection events using
41+ ` setOnNavigationItemSelectedListener(...) ` .
4442
4543A typical layout file would look something like this:
4644
@@ -66,6 +64,31 @@ A typical layout file would look something like this:
6664</FrameLayout >
6765```
6866
67+ ### Badges
68+
69+ ![ Bottom Navigation with badges] ( assets/bottom-navigation-badges.png )
70+
71+ ` BottomNavigationView ` supports displaying icon and number badges.
72+
73+ Initializes and shows a BadgeDrawable associated with menuItemId. Subsequent
74+ calls to this method will reuse the existing BadgeDrawable.
75+
76+ ``` java
77+ BadgeDrawable badge = bottomNavigationView. showBadge(menuItemId);
78+ ```
79+ NOTE: Don't forget to remove any BadgeDrawables that are no longer needed.
80+
81+ ``` java
82+ bottomNavigationView. removeBadge(menuItemId);
83+ ```
84+
85+ Best Practice: If you only need to temporarily hide the badge(e.g. until the next
86+ notification is received), the recommended/lightweight alternative is to change
87+ the visibility of the BadgeDrawable instead.
88+
89+ Please see [ ` BadgeDrawable ` ] ( BadgeDrawable.md ) for details on how to update the
90+ badge content being displayed.
91+
6992### Handling States
7093
7194The ` app:itemIconTint ` and ` app:itemTextColor ` take a
@@ -191,8 +214,8 @@ theming attributes.
191214There are other navigation patterns you should be aware of:
192215
193216- [ Hierarchical navigation] ( https://developer.android.com/training/implementing-navigation/index.html ) .
194- * See also [ Navigation with Back and
195- Up] ( https://developer.android.com/design/patterns/navigation.html ) .*
217+ * See also
218+ [ Navigation with Back and Up] ( https://developer.android.com/design/patterns/navigation.html ) .*
196219- Swipeable tabs using [ TabLayout] ( TabLayout.md ) and
197220 [ ViewPager] ( https://developer.android.com/reference/android/support/v4/view/ViewPager.html ) .
198221- Using [ NavigationView] ( NavigationView.md ) to display a longer list of
0 commit comments