Mehul Kanzariya
Mehul Kanzariya

Reputation: 1348

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.

Upvotes: 4

Views: 4935

Answers (2)

J-me
J-me

Reputation: 424

Elevation has been fixed in the Android material components 1.1.0 (alpha) release according to this commit.

Edit

for those wondering, this is how you add the new dependency:

dependencies {
    // ...
    implementation 'com.google.android.material:material:1.1.0-alpha02'
    // ...
}

More information about getting started can be found here and info about releases can be found here.

Cheers!

Upvotes: 2

Mehul Kanzariya
Mehul Kanzariya

Reputation: 1348

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"/>

Upvotes: 6

Related Questions