How to add shadow to the FAB provided with the android support design library?

Rolf ツ picture Rolf ツ · May 29, 2015 · Viewed 39.2k times · Source

The title is pretty self explaining.

The following code does not render shadow below the Floating Action Button. What can be done to render shadow? Is this feature really not supported even on API 21+?

<android.support.design.widget.FloatingActionButton
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/ic_add"
    android:clickable="true" />

Note: Adding android:elevation does not add shadow on API 21.

Example screenshot

Screenshot taken from the example by dandar3: https://github.com/dandar3/android-support-design

Answer

Dmytro Danylyk picture Dmytro Danylyk · May 29, 2015

Simply setting app:borderWidth="0dp" resolve this issues for me.

Note: don't forget to add xmlns:app="http://schemas.android.com/apk/res-auto" to your root layout.

This issue should be fixed in next release of android design library.