1

How can I add a divider in the Bottom Navigation view? Basically a separator between the icons

Thank you

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Snake
  • 14,228
  • 27
  • 117
  • 250
  • Have u check this https://stackoverflow.com/a/43140077/7666442 and this https://stackoverflow.com/questions/30625280/how-to-create-a-simple-divider-in-the-new-navigationview – AskNilesh Jan 05 '19 at 07:25
  • Yes I did, first one does not work. No idea why it is accepted answer. Second one is for navigation view not bottom navigation. You can't do groups for bottom navogation – Snake Jan 05 '19 at 19:24

2 Answers2

0

If I'm not wrong, the bottom navigation view has been created to match/follow Material Design guidelines and dividers are not supposed to be part of bottom navigation. https://material.io/design/components/bottom-navigation.html

nyulan
  • 311
  • 3
  • 12
0

You can easily create a divider between items something like that.

  <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigation"
        style="@style/BottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:layout_gravity="bottom"
        android:background="@drawable/item_bg"
        android:focusable="false"
        android:foreground="@drawable/ripple"
        android:theme="@style/BottomNavigationTheme"
        app:itemIconSize="@dimen/dimen_20dp"
        app:itemIconTint="@drawable/bottom_navigation_selector"
        app:itemTextColor="@color/color_selector"
        app:labelVisibilityMode="labeled"
        app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
        app:layout_scrollFlags="scroll|enterAlways|snap">

        <androidx.appcompat.widget.AppCompatTextView
            android:id="@+id/line"
            android:layout_width="0.8dp"
            android:layout_height="@dimen/dimen_20dp"
            android:layout_marginTop="@dimen/dimen_5dp"
            android:layout_gravity="center"
            android:background="@color/textview_black">

        </androidx.appcompat.widget.AppCompatTextView>


    </com.google.android.material.bottomnavigation.BottomNavigationView>