I have an activity with two buttons under content. First button is usual FloatingActionButton. Second button is my own custom button in top part of activity. Second button should be styled like first button. Here is no problem to set same background color. But how to copy shadow from FloatingActionButton?
Asked
Active
Viewed 972 times
2 Answers
3
Use elevation tag in your button to achieve shadow effect
like
android:elevation="3dp"
For pre-lollipop devices create drawable resource file
like this
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#BDBDBD"/>
<corners android:radius="5dp"/>
</shape>
</item>
<item
android:left="0dp"
android:right="0dp"
android:top="0dp"
android:bottom="2dp">
<shape android:shape="rectangle">
<solid android:color="#ffffff"/>
<corners android:radius="5dp"/>
</shape>
</item>
</layer-list>
And, use as a background to button
android:background="drawable/you_xml_file"

Milind Mevada
- 3,145
- 1
- 14
- 22
-
@BArtWell : If it's working consider as the accepted answer. – Milind Mevada Aug 08 '18 at 11:36
-2
As described in the documentation, by default it takes the color set in styles.xml attribute colorAccent.
Use Google before ask something, here the same question. Android changing Floating Action Button color