在自定义导航抽屉连锁反应 [英] Ripple effect on custom navigation drawer

查看:219
本文介绍了在自定义导航抽屉连锁反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展我的第一个应用程序提供给它的新材料的外观。我有点这个失去了,所以我下面的一些教程,以实现像工具​​栏,导航抽屉等。我不得不说,我做的是提供兼容性,pre-棒棒糖的Andr​​oid版本,所以我敢用支持库。

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.

什么concers我的问题,就是我刚才实现导航抽屉下面这个教程之一,使用下列库的兼容性:

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

我认为,code实现太长,把它放在这儿,所以我会提供连结此教程中,我已经做了完全一样说的这里

我的问题是,当我从导航抽屉的行的一个项目,它完美地打开它的通讯员frament,但是,它并没有表现出任何的连锁反应,或只是任何触摸效果,触摸它的时候。事情是这样的:

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:

我已采取一看就一些其他教程,例如,一到属于所附的gif,看他们是否使用任何方法或实施,以提供效应的触摸,但没有被实现来获取实际上,刚刚的onclick方法。

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.

那么,有什么不对的code和我怎么能修改它,或者我能怎么增加获得这种效果?

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

推荐答案

由于您使用的是appcompat你可以把它添加到XML为您导航抽屉项安卓背景=ATTR / selectableItemBackground?

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.

这篇关于在自定义导航抽屉连锁反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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