Android design library FAB no shadow

839 views Asked by At

for some reason my FAB displays no shadow, even though I have set the elevation and the border width to 0, like it was described in many blogs. That should fix the issue. I am placing the fab above the toolbar to get the material design guideline look.

Here is my code:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include android:id="@+id/toolbar" layout="@layout/toolbar_extended" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_navigate"
        android:layout_alignParentRight="true"
        android:layout_marginTop="88dp"
        android:layout_marginRight="16dp"
        android:layout_marginBottom="16dp"
        android:layout_marginLeft="16dp"
        app:backgroundTint="@color/accent_yellow"
        app:borderWidth="0dp"
        app:elevation="8dp"
        app:pressedTranslationZ="12dp"
        app:fabSize="normal"
        app:rippleColor="@color/accent_dark_yellow" />

</RelativeLayout>

Toolbar:

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="116dp"
    android:background="?attr/colorPrimary"
    android:elevation="4dp"
    android:fitsSystemWindows="true"
    android:minHeight="?android:attr/actionBarSize"
    app:navigationIcon="@drawable/abc_ic_ab_back_mtrl_am_alpha"/>
2

There are 2 answers

0
Markus Rubey On BEST ANSWER

Change xmlns:app="http://schemas.android.com/tools" to xmlns:app="http://schemas.android.com/apk/res-auto".

0
000 On

Setting

app:borderWidth="0dp" in addition to adding the namespace xmlns:app="http://schemas.android.com/apk/res-auto"