Android Bottom Navigation Bar With Drop Shadow


Answer :

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.


You can use elevation to add shadows to any view

<TextView android:id="@+id/myview" ... android:elevation="2dp"  android:background="@drawable/myrect" /> 

Refer this for more information


For those using a CoordinatorLayout with the Bottom Navigation Bar (or BottomAppBar), you can use the following to attach a shadow above the bar:

<View     android:layout_width="match_parent"     android:layout_height="4dp"     android:background="@drawable/shadow"     app:layout_anchor="@+id/toolbar"     app:layout_anchorGravity="top"/> 

Obviously, replace the @+id/toolbar with the id of the Bottom Navigation Bar


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable