简体   繁体   English

如何禁用快速点击的 Android 涟漪效应?

[英]How to disable the Android ripple effect for quick taps?

In certain apps like Google Play, quickly tapping / clicking views do not show a ripple effect.在 Google Play 等某些应用程序中,快速点击/点击视图不会显示涟漪效应。

If you long press an element the ripple is shown.如果您长按某个元素,则会显示波纹。

How is this effect achieved?这个效果是如何实现的?

Thanks谢谢

尝试在布局中设置属性视图:android:clickable="false"

AFAIK You need to set other selector on that view. AFAIK 您需要在该视图上设置其他选择器。 Ripple effect uses sectors which have "ripple" node in the xml.波纹效果使用在 xml 中具有“波纹”节点的扇区。 Just use old type of selectors for Android <21 and it should work tag you want.只需为 Android <21 使用旧类型的选择器,它应该可以使用您想要的标签。

I think what you are looking for is app:rippleColor attribute (if Material design library is used).我认为您正在寻找的是app:rippleColor属性(如果使用材料设计库)。 So if you want to disable the ripple effect on a Button for example, set its ripple color to transparent :因此,例如,如果您想禁用Button上的波纹效果,请将其波纹颜色设置为透明

<com.google.android.material.button.MaterialButton
    ...
    app:rippleColor="@android:color/transparent" />

I've already answered anther similar question .我已经回答了另一个类似的问题

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

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