有人知道如何实现一个滑动菜单像一些顶级应用程序的今天?

其他Stack Overflow问题还没有关于如何做到这一点的任何答案,所以我正试图收集尽可能多的信息来帮助其他人。下面我提到的所有应用程序都很好地实现了幻灯片菜单。

1. 谷歌Plus(截至12年7月7日)

您只能通过单击左上角的G+标志从第一个屏幕切换到第二个屏幕。注意,整个屏幕从它的位置移动到屏幕的右侧(包括操作栏)。要回到第一个屏幕,您可以将右侧滑回焦点,或者再次单击G+图标。

2. YouTube(截至12年7月7日)

您可以使用两种方法从第一个屏幕切换到第二个屏幕。你可以点击左上角的YouTube logo,也可以用滑动手势把它移到右边。这已经不同于G+应用程序。其次,你可以看到操作栏保持不变(不像G+)。最后,为了恢复原来的屏幕,它就像G+一样工作。


编辑# 3:

导航抽屉模式在Android文档中有正式的描述!

请参阅以下连结:

设计文件可以在这里找到。 开发者文档可以在这里找到。


编辑# 2:

罗曼·努里克(谷歌的Android设计工程师)已经证实,推荐的行为是在打开抽屉时不要移动操作栏(就像YouTube应用程序一样)。看看这个谷歌+帖子。


编辑# 1:

我之前回答过这个问题,但我再次强调Prixing拥有最好的飞出菜单……到目前为止。它非常漂亮,非常流畅,它让Facebook,谷歌+和YouTube相形见绌。EverNote也很不错…但仍不如Prixing完美。看看这一系列关于如何实现飞出菜单的帖子(来自Prixing的首席开发人员本人!)


最初的回答:

Adam Powell和Richard Fulcher在49:47 - 52:50的谷歌I/O演讲中谈到了这个主题为“Android中的导航”。

总结一下他们的回答,在这篇文章发布之日,滑出导航菜单还不是Android应用设计标准的正式组成部分。您可能已经发现,目前没有对该特性的原生支持,但是曾经有过将其添加到即将发布的支持包修订中的讨论。

至于YouTube和G+应用程序,它们的表现不同似乎很奇怪。我最好的猜测是,YouTube应用程序固定操作栏位置的原因是,

One of the most important navigational options for users using the YouTube app is search, which is performed in the SearchView in the action bar. It would make sense to make the action bar static in this regard, since it would allow the user to always have the option to search for new videos. The G+ app uses a ViewPager to display its content, so making the pull out menu specific to the layout content (i.e. everything under the action bar) wouldn't make much sense. Swiping is supposed to provide a means of navigating between pages, not a means of global navigation. This might be why they decided to do it differently in the G+ app than they did in the YouTube app. On another note, check out the Google Play app for another version of the "pull out menu" (when you are at the left most page, swipe left and a pull out, "half-page" menu will appear).

你是对的,这并不是非常一致的行为,但似乎在Android团队中,对于这种行为应该如何实现还没有100%的共识。如果未来应用程序更新后,两个应用程序的导航完全相同,我也不会感到惊讶(他们似乎非常热衷于在所有谷歌制造的应用程序中保持导航一致)。

就在最近,我分叉了一个当前的Github项目,名为“RibbonMenu”,并编辑它以满足我的需求:

https://github.com/jaredsburrows/RibbonMenu

目的是什么

易于访问:可以方便地访问滑动的菜单 易于实现:使用最少的代码更新相同的屏幕 独立性:不需要ActionBarSherlock等支持库 自定义:轻松更改颜色和菜单

有什么新鲜事

Changed the sliding animation to match Facebook and Google+ apps Added standard ActionBar (you can chose to use ActionBarSherlock) Used menuitem to open the Menu Added ability to update ListView on main Activity Added 2 ListViews to the Menu, similiar to Facebook and Google+ apps Added a AutoCompleteTextView and a Button as well to show examples of implemenation Added method to allow users to hit the 'back button' to hide the menu when it is open Allows users to interact with background(main ListView) and the menu at the same time unlike the Facebook and Google+ apps!

带菜单的动作栏

动作栏的菜单和搜索选择

就我个人而言,我喜欢谷歌Drive官方应用程序中的导航抽屉。它非常好用。我同意导航抽屉不应该移动操作条,因为这是打开和关闭导航抽屉的关键点。

如果你仍然试图得到这种行为,我最近创建了一个名为SherlockNavigationDrawer的项目,正如你所期望的是导航抽屉与ActionBarSherlock的实现,并适用于pre Honeycomb设备。检查:

夏洛克导航抽屉 github

有一个伟大的实现NavigationDrawer遵循谷歌材料设计指南(兼容API 10) - MaterialDrawer库(链接到GitHub)。截至2017年5月撰写本文时,它得到了积极的支持。

它可以在Maven Central repo中获得。 Gradle依赖设置:

compile 'com.mikepenz:materialdrawer:5.9.1'

Maven依赖项设置:

<dependency>
    <groupId>com.mikepenz</groupId>
    <artifactId>materialdrawer</artifactId>
    <version>5.9.1</version>
</dependency>

我知道这是一个老问题,但最新的答案是使用Android支持设计库,这将使您的生活变得简单。