问题描述
在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上禁用波纹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!