Fab in Lollipop 在长按时显示奇怪的阴影

Fab in Lollipop shows strange shadow on long press

我在 CoordinatorLayout 中使用 FloatingActionButton:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab_add"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:tint="@color/white"
    app:fabSize="normal"
    app:layout_anchor="@+id/view_pager_imageformat_carousel"
    app:layout_anchorGravity="bottom|end"
    app:srcCompat="@drawable/ic_playlist_add_black_24dp"
    app:useCompatPadding="true" />

它适用于大多数 Android Apis,但在 Android 5 和 5.1 中显示 boxed shadow被按下:

->

我尝试在 CoordinatorLayout 中将 clipChildren 设置为 false,但没有任何效果,并且查看了其他可用选项,但到目前为止都没有成功。

有没有人遇到过同样的问题并提出了解决方案?

尝试设置海拔:

app:elevation="0dp"

原来罪魁祸首是useCompatPadding

删除它解决了阴影问题。

为了修复我使用的边距 它基本上使用具有两种不同样式的自定义边距,default 和 ond for api 21+

但这实际上是一个丑陋的解决方案,而且边距并不完美,所以我愿意接受更好的解决方案。

您可以添加 app:rippleColor="@color/transparent" 将波纹颜色设置为透明。