qwertz
qwertz

Reputation: 6286

Android design library FAB no shadow

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"/>

Upvotes: 2

Views: 839

Answers (2)

000
000

Reputation: 51

Setting

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

Upvotes: 0

Markus Rubey
Markus Rubey

Reputation: 5238

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

Upvotes: 2

Related Questions