4

I want to add shadow effect (or elevation) to the vector drawable.

for example

1.My first file contains a download icon in ic_file_download_black_24dp.xml

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="48dp"
    android:height="48dp"
    android:viewportWidth="24.0"
    android:viewportHeight="24.0">
<path
    android:fillColor="#FF2e2e2e"
    android:pathData="M19,9h-4V3H9v6H5l7,7 7,-7zM5,18v2h14v-2H5z"/>

2.My second file contains a round shape in round_shape.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="oval">
    <solid android:color="#fffbc02d" />
    <corners
        android:bottomLeftRadius="8dp"
        android:bottomRightRadius="8dp"
        android:topLeftRadius="8dp"
        android:topRightRadius="8dp" />
</shape>

3.Now, I'm combining these two files to create single layered-drawable like this which called layered_download_icon.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/round_shape" />
    <item android:drawable="@drawable/ic_file_download_black_24dp" />
</layer-list>

Which gives me the overall image as shown below

enter image description here

Now I want to give elevation to the download icon placed inside the yellow circle. How can I able to achieve that??

P.S. I'm setting layered_download_icon to srcCompat in my ImageButton.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Jay Patel
  • 2,341
  • 2
  • 22
  • 43

0 Answers0