Search code examples
androidandroid-support-libraryandroid-support-designandroid-bottomnav

Android Bottom Navigation Bar with drop shadow


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


Solution

  • 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.