How to remove grey shadow color below FloatingActi

2019-08-09 16:46发布

I am getting light grey color below the FloatingActionButton as shown in image. Any one know how to remove it. I tested it on Lollipop version.

My xml code

<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_alignParentRight="true"
    android:src="@drawable/ic_add_black"
    app:borderWidth="0dp"
    app:fabSize="mini"
    app:rippleColor="@color/colorPrimaryDark" />

Floating action button

3条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-09 17:21

It happens when you set an elevation and the fab element has not space enough to display the "shadow".

Then you can set the elevation as 0dp as suggested above, or set a margin like

<android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_build_white_36dp"
    android:id="@+id/build"
    app:elevation="4dp"
    android:clickable="true"
    android:layout_margin="10dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true" />

In this way the "elevation-effect" will appear correctly

查看更多
手持菜刀,她持情操
3楼-- · 2019-08-09 17:24

You can overwrite the elevation of a FAB with:

android:elevation="0dp"

or

View.setElevation(float)

I found this by searching on Google – try finding an answer that way next time.

查看更多
Viruses.
4楼-- · 2019-08-09 17:32

Try set elevation:

app:elevation="0dp"

查看更多
登录 后发表回答