I am currently learning android and wanted to make a button that has elevation effect in it. To be more precise I want elevation effect like the image below.
Can anyone help me on how to make this type of button in android studio?
I am currently learning android and wanted to make a button that has elevation effect in it. To be more precise I want elevation effect like the image below.
Can anyone help me on how to make this type of button in android studio?
Add a XML file in drawable folder and name it a.xml:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Gray shadow. -->
<item android:left="3dp" android:top="5dp">
<shape>
<solid android:color="@android:color/darker_gray" />
<corners android:radius="15dp" />
</shape>
</item>
<!-- White foreground. -->
<item android:bottom="5dp" android:right="3dp">
<shape>
<solid android:color="@android:color/white" />
<corners android:radius="15dp" />
</shape>
</item>
</layer-list>
Add in your button:
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:ackground="@drawable/a.xml"
android:text="Button" />
Output:
You just need to add below line to Button tag in xml. It will add elevation as you wanted.
android:stateListAnimator="@null"