How do I add elevation (shadow) to my BottomNavigationView. It doesn't come by default

Javed Khatri picture Javed Khatri · Nov 23, 2016 · Viewed 9.9k times · Source

I tried setting elevation from xml and programmatically both. But nothing works.enter image description here

Answer

nellorocca picture nellorocca · Feb 24, 2017

It only works if you set white as android:background in the BottomNavigationView.

This is my code and it's working:

<android.support.design.widget.BottomNavigationView
    android:id="@+id/bottom_navigation"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="@color/white"
    app:elevation="8dp"
    app:itemIconTint="@color/bottom_color_state"
    app:itemTextColor="@color/bottom_color_state"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintHorizontal_bias="0.52"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:menu="@menu/bottom_navigation_main" />