Android design library FAB no shadow

时间:2015-06-15 14:24:45

标签: android android-actionbar android-toolbar floating-action-button androiddesignsupport

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 个答案:

答案 0 :(得分:2)

xmlns:app="http://schemas.android.com/tools"更改为xmlns:app="http://schemas.android.com/apk/res-auto"

答案 1 :(得分:0)

设置

应用程式:边框宽度=&#34; 0dp&#34;  除了添加命名空间 的xmlns:应用程式=&#34; HTTP://schemas.android.com/apk/res-auto"