Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shadow at the top of Bottom App Bar

I am using the new Bottom App Bar from the Material Design Components. I am trying to give shadow at the top of the Bottom App Bar like the one in Google Tasks app as shown below.

enter image description here

I have tried using both android:elevation and app:elevation attribute. Please help.

like image 665
Mehul Kanzariya Avatar asked Jan 27 '23 17:01

Mehul Kanzariya


1 Answers

I ended up using this solution.


Step 1 Create a shape_drawable.xml file in the drawable folder as shown below:

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

Step 2 Create a View, set the shape_drawable.xml as its background and then place the view just above the BottomAppBar.

<View
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_above="@id/bottom_bar"
android:background="@drawable/shape_drawable"/>
like image 149
Mehul Kanzariya Avatar answered Jan 31 '23 18:01

Mehul Kanzariya