I have a floating action button anchored to the bottom right of a coordinator layout. It is 16dp from the margins of the view (the margins are included by default and specified in the dimens.xml
file), but its shadow is clipping and has a square-shape appearance (see below). When I move the floating action button to 32dp from the margins of the view, its shadow displays properly.
I have tried setting its elevation attribute (android:elevation="5dp"
), but that seems to have no effect. I have also tried setting the attribute borderWidth to 0 (app:borderWidth="0dp"
) but that also had no effect.
Is there a reason the floating action button is behaving like this?
XML
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<android.support.design.widget.FloatingActionButton
android:id="@+id/create_floating_action_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_create_white_48dp"
app:layout_anchor="@id/coordinator_layout"
app:layout_anchorGravity="bottom|right" />
</android.support.design.widget.CoordinatorLayout>
Images