在ListView上禁用波纹 [英] Disable Ripple on ListView

查看:491
本文介绍了在ListView上禁用波纹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android 5.0中,单击列表项时,我的ListView会产生波纹效果.有没有办法禁用此效果?查看文档,我看不到任何方式( https://developer. android.com/reference/android/widget/ListView.html )

In Android 5.0, my ListView produces a ripple effect when clicking a list item. Is there a way to disable this effect? Looking at the docs, I don't see any way (https://developer.android.com/reference/android/widget/ListView.html)

推荐答案

您可以使用android:listSelector属性删除或替换列表选择器.材质下的默认列表选择器是?android:attr/selectableItemBackground,这是一个有界波纹.

You can remove or replace the list selector using the android:listSelector property. The default list selector under Material is ?android:attr/selectableItemBackground which is a bounded ripple.

<ListView
    ...
    android:listSelector="@drawable/my_list_selector" />

要完全禁用选择器,可以使用@null@android:color/transparent(在某些Android版本上更好)的值,如下所示:

To completely disable selector, you can use a @null or @android:color/transparent (works better for some Android versions) value as following:

<ListView
    ...
    android:listSelector="@android:color/transparent" />

这篇关于在ListView上禁用波纹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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