簡體   English   中英

Android 設計庫 FAB 無影

[英]Android design library FAB no shadow

出於某種原因,我的 FAB 不顯示陰影,即使我已將高程和邊框寬度設置為 0,就像許多博客中所描述的那樣。 那應該可以解決問題。 我將 fab 放置在工具欄上方以獲得材料設計指南的外觀。

這是我的代碼:

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

工具欄:

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

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

環境

app:borderWidth="0dp" 除了添加命名空間 xmlns:app="http://schemas.android.com/apk/res-auto"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM