Search code examples
androidbottomnavigationview

BottomNavigationView Disabling the grey box when clicking on an item


How do I disable that greybox that appears when you click/hold on a bottomnavigation menu item?

<android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:menu="@menu/bottom_navigation_menu"
        android:id="@+id/bottom_navigation"
        android:background="@color/colorWhite"
        app:labelVisibilityMode="unlabeled"
        app:itemIconSize="26dp"/>

Solution

  • You can disable or change the selector by using app:itemBackground attribute. Use @null to disable it or use a custom selector drawable to change it (Do remember to create a drawable according to api version drawable, drawable-v21, drawable -v24 if you want that ripple effect).

    <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:menu="@menu/bottom_navigation_menu"
        android:id="@+id/bottom_navigation"
        app:itemBackground="@null"
        android:background="@color/colorWhite"
        app:labelVisibilityMode="unlabeled"
        app:itemIconSize="26dp"/>