简体   繁体   中英

Disable ripple effect on Listview

I have a simple listview that has some listitems. Currently, to make the items ripple on touch, I just added android:drawSelectorOnTop="true" to the listview.

This works perfectly.

However, some of the list items are headers and should not show ripples because they do not have an action associated with them. How can I disable the ripple effect for only the headers?

The listview contains linearlayouts for the rows and the headers.

I tried the following on the header with no success:

  • setting clickable to false
  • setting listSelector to null.
  • setting focusable to false.

Can anyone point me in the right direction?

Possibly a duplicate question . But as a summary: try disabling those elements in your adapter. You can use the .areAllItemsEnabled() and .isEnabled() callbacks for this purpose.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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