简体   繁体   中英

FloatingActionButton (FAB) with Android Design support library not elevating

This is my FAB button:

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom"
        android:layout_margin="16dp"
        android:src="@drawable/c"
        app:elevation="6dp"
        app:backgroundTint="#fa1d1d" />

I'm using the Design support lib: compile 'com.android.support:design:23.1.1' and testing on Android 6.0.1

The main problem is that regardless of the value I set for elevation , it looks the same every time. Here's the screenshot. First button has elevation set to 6, then 12, then 24

Feels like I'm missing something really simple.

在此处输入图片说明

It looks correct to me, I believe that you're misinterpreting the meaning of the elevation. Elevation only changes the shadow that is drawn under the view. From the docs:

The elevation of a view (...) determines the visual appearance of its shadow

( http://developer.android.com/training/material/shadows-clipping.html )

If you inspect closely, you'll see that the last button, the shadow is bigger and more "spread out".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM