Android Bottom Navigation Bar with drop shadow

Jan Slominski picture Jan Slominski · Jan 14, 2017 · Viewed 26.3k times · Source

I'm implementing Bottom Navigation Bar in Android app using Google's support design library v25.1.0. Is there any way to add drop shadow effect, same as current Android native Google Photos app?

enter image description here

Answer

Alexander Bilchuk picture Alexander Bilchuk · Jan 14, 2017

You can draw your own shadow just above the bottom bar using simple View and its background:

<View
    android:layout_width="match_parent"
    android:layout_height="4dp"
    android:layout_above="@id/bottom_bar"
    android:background="@drawable/shadow"/>

drawable/shadow.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <gradient
        android:startColor="#1F000000"
        android:endColor="@android:color/transparent"
        android:angle="90" />
</shape>

Also, there are no compatibility issues if use this approach.