棒棒糖中的Fab在长时间按下时显示出奇怪的阴影 [英] Fab in Lollipop shows strange shadow on long press

查看:107
本文介绍了棒棒糖中的Fab在长时间按下时显示出奇怪的阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在CoordinatorLayout中使用 FloatingActionButton :

I am using the FloatingActionButton in a CoordinatorLayout:

<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 中,当按下时,它会显示一个装箱的阴影:

and it works fine with most Android Apis, but in Android 5 and 5.1 it shows a boxed shadow when it is pressed:

->

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

I tried setting clipChildren to false in the CoordinatorLayout, without any effect and looked through other available options wihtout success so far.

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

Has anyone encountered the same problem and came up with a solution?

推荐答案

原来,罪魁祸首是useCompatPadding.

删除它可以解决阴影问题.

Removing it solved the shadow problem.

为解决利润问题,我使用了此答案 它基本上使用两种不同样式的自定义边距,即api 21+的default和ond

To fix the margins I used this answer which basically uses custom margins with two different styles, default and ond for api 21+

但这实际上是一个丑陋的解决方案,利润空间也不尽人意,因此我愿意寻求更好的解决方案.

But this is in fact an ugly solution and the margins are not perfect, so I am open to better solutions.

这篇关于棒棒糖中的Fab在长时间按下时显示出奇怪的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆