Ripple effect on custom navigation drawer

Deadly 提交于 2019-12-05 22:01:12

问题


I'm developing my first app providing to it the new material look. I'm a bit lost with this so I'm following some tutorials to implement things like Toolbar, Navigation Drawer, etc. I have to say that I'm doing it providing compatibility to pre-lollipop android versions, so I'm using support libraries.

What concers to my question, is that I have just implemented the Navigation Drawer following one of this tutorials and using the following libraries for compatibility:

support.v4.widget.DrawerLayout
support.v7.widget.RecyclerView

I think that the code implementation is too long to put it here, so I'll provide the link to this tutorial, I have done it exactly as is said here.

My problem is that, when I select one item from the navigation drawer's row, it perfectly opens it correspondant frament, but, it doesn't show any ripple effect, or simply any touch effect, when touching it. Something like this:

I have taken a look to some other tutorials, for example, to the one to which belongs the attached gif, to see if they use any method or implementation to provide that efect to the touch, but nothing is implemented to get that effect, just the onclick method.

So, what's wrong with this code, and how could I modify it, or what could I add to get that effect?


回答1:


As you are using appcompat you can add this to the XML for your navigation drawer item android:background="?attr/selectableItemBackground".

This should provide the ripple effect on Lollipop devices and a fallback grey highlight for older devices.



来源:https://stackoverflow.com/questions/30477525/ripple-effect-on-custom-navigation-drawer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!