How to remove FloatingActionButton's surrounding shadow?

tounaobun picture tounaobun · Jun 3, 2015 · Viewed 20.9k times · Source

I'm trying to replace the third party FloatingActionButton with the native one which is packaged in library com.android.support:design:22.2.0.The default look has a dark shadow around the image,How can I get rid of it? I know the former one provides with the method setShadow(),but I just can't find similar one from the latter.

enter image description here

This is the related XML layout:

<android.support.design.widget.FloatingActionButton
        android:id="@+id/alarm_front"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/btn_icon_alarm_notset" />

And I have set its background color to yellow.

mAlarmBtn.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.floatButtonColor)));

Answer

BrentM picture BrentM · Jun 3, 2015

Override the default elevation of the FAB by adding:

android:elevation="0dp"

Or in code call View.setElevation(float)