简体   繁体   English

浮动动作按钮上的阴影

[英]Shadow on floating action button

For some reason a small shadow appears on top of my floating action button as seen here but only on the debugging device but not in the Android Studio preview. 由于某种原因,我的浮动操作按钮上方会出现一个小阴影,如此处所示但仅在调试设备上,而在Android Studio预览中则没有。

The button is nested in a relative layout to position it in the bottom of the screen like this: 该按钮嵌套在相对布局中,以将其放置在屏幕底部,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        android:layout_margin="16dp"
        android:src="@drawable/baseline_play_circle_outline_white_36" />
</RelativeLayout>

Update: 更新:

This is what it looks like when clicked. 就是单击时的样子。 The problem is also caused by adding an alpha value to the FAB like here but in my case, as the shadow color is almost the same as the original, adding 0.9 alpha makes it way less obvious. 这个问题也是由像这样 FAB中添加alpha值引起的,但在我的情况下,由于阴影颜色与原始颜色几乎相同,因此添加0.9 alpha使其不那么明显。

try adding following attributes to fab : 尝试向fab添加以下属性:

android:clipChildren="false"
android:clipToPadding="false"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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