本文翻译自:Navigation Drawer (Google+ vs. YouTube) Does anyone know how to implement a sliding menu like some of the top apps of today? 有谁知道如何实现像今天的一些顶级应用程序的滑动菜单?
Other Stack Overflow questions haven't had any answers on how to do this, so I'm trying to gather as much info to help out others. 其他Stack Overflow 问题对于如何做到这一点没有任何答案,所以我试图收集尽可能多的信息来帮助其他人。 All the applications I mention below do a great job of implementing the slide menu. 我在下面提到的所有应用程序都可以很好地实现幻灯片菜单。
1. Google Plus (as of 7/7/12) 1. Google Plus(截至2012年7月7日)

You can only go from the first screen to the second screen by clicking the G+ logo in the upper left hand corner. 您只能通过单击左上角的G +徽标从第一个屏幕转到第二个屏幕。 Notice that the entire screen moves from it's position and get's nudged to the right side of the screen (including the action bar). 请注意,整个屏幕从其位置移动并轻推到屏幕右侧(包括操作栏)。 To get back to the first screen you can either slide the right side back into focus or you can click the G+ icon again. 要返回第一个屏幕,您可以将右侧滑回焦点,也可以再次单击G +图标。
2. YouTube (as of 7/7/12) 2. YouTube(截至2012年7月7日)

You can go from the first screen to second screen using two methods. 您可以使用两种方法从第一个屏幕进入第二个屏幕。 Either click the YouTube logo in the upper left, or you can use a swipe gesture to move it to the right. 您可以点击左上方的YouTube徽标,也可以使用滑动手势将其移到右侧。 This is already different from the G+ app. 这已经与G + app不同了。 Secondly, you can see that the action bar stays put (Unlike G+). 其次,您可以看到操作栏保持不变(与G +不同)。 Lastly, to get the original screen back it works just like G+. 最后,为了获得原始屏幕,它就像G +一样工作。
#1楼参考:https://stackoom.com/question/ljnc/导航抽屉-Google-与YouTube
#2楼 Edit #3: 编辑#3:
The Navigation Drawer pattern is officially described in the Android documentation! 导航抽屉模式在Android文档中正式描述!
Check out the following links: 查看以下链接:
- Design docs can be found here . 设计文档可以在这里找到。
- Developer docs can be found here . 开发人员文档可以在这里找到。
Edit #2: 编辑#2:
Roman Nurik (an Android design engineer at Google) has confirmed that the recommended behavior is to not move the Action Bar when opening the drawer (like the YouTube app). Roman Nurik(Google的Android设计工程师)已确认建议的行为是在打开抽屉时不移动操作栏(如YouTube应用程序)。 See this Google+ post . 查看此Google+信息 。
Edit #1: 编辑#1:
I answered this question a while ago, but I'm back to re-emphasize that Prixing has the best fly-out menu out there... by far . 我刚才回答了这个问题,但我又重新强调, Prixing有最好的飞出菜单......到目前为止 。 It's absolutely beautiful, perfectly smooth, and it puts Facebook, Google+, and YouTube to shame. 这绝对是美丽的,非常流畅,它让Facebook,Google +和YouTube蒙羞。 EverNote is pretty good too... but still not as perfect as Prixing. EverNote也很不错......但仍然不如Prixing那么完美。 Check out this series of posts on how the flyout menu was implemented (from none other than the head developer at Prixing himself!). 查看关于如何实施弹出菜单的这一系列帖子 (来自Prixing本人的首席开发人员!)。
Original Answer: 原答案:
Adam Powell and Richard Fulcher talk about this at 49:47 - 52:50 in the Google I/O talk titled "Navigation in Android". Adam Powell和Richard Fulcher在49:47 - 52:50的Google I / O谈话中谈到了这一点,题为“Android中的导航”。
To summarize their answer, as of the date of this posting the slide out navigation menu is not officially part of the Android application design standard. 为了总结他们的答案,截至本发布日期,滑出导航菜单不是 Android应用程序设计标准的正式部分。 As you have probably discovered, there's currently no native support for this feature, but there was talk about making this an addition to an upcoming revision of the support package. 正如您可能已经发现的那样,目前没有对此功能的原生支持,但有人谈到将此添加到即将推出的支持包修订版中。
With regards to the YouTube and G+ apps, it does seem odd that they behave differently. 关于YouTube和G +应用程序,它们表现不同似乎很奇怪。 My best guess is that the reason the YouTube app fixes the position of the action bar is, 我最好的猜测是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. 使用YouTube应用的用户最重要的导航选项之一是搜索,该操作在操作栏的SearchView 中执行。 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 (ie everything under the action bar) wouldn't make much sense. G +应用程序使用ViewPager 来显示其内容,因此制作特定于布局内容的拉出菜单(即操作栏下的所有内容)都没有多大意义。 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. 这可能就是为什么他们决定在G +应用程序中使用不同于YouTube应用程序的方式。 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). 另请注意,请查看Google Play应用以获取其他版本的“拉出菜单”(当您位于最左侧页面时,向左滑动并拉出,“半页”菜单将会出现)。
You're right in that this isn't very consistent behavior, but it doesn't seem like there is a 100% consensus within the Android team on how this behavior should be implemented yet. 你是对的,这不是非常一致的行为,但似乎在Android团队中对于如何实现这种行为没有100%的共识。 I wouldn't be surprised if in the future the apps are updated so that the navigation in both apps are identical (they seemed very keen on making navigation consistent across all Google-made apps in the talk). 如果将来应用程序更新以便两个应用程序中的导航相同(我们似乎非常热衷于在谈话中使所有Google制造的应用程序中的导航保持一致),我不会感到惊讶。
#3楼 Just recently I forked a current Github project called "RibbonMenu" and edited it to fit my needs: 就在最近,我分叉了一个名为“RibbonMenu”的当前Github项目并编辑它以满足我的需求:
https://github.com/jaredsburrows/RibbonMenu https://github.com/jaredsburrows/RibbonMenu
What's the Purpose 目的是什么?
- Ease of Access: Allow easy access to a menu that slides in and out 易于访问:允许轻松访问滑入和滑出的菜单
- Ease of Implementation: Update the same screen using minimal amount of code 易于实施:使用最少量的代码更新同一屏幕
- Independency: Does not require support libraries such as ActionBarSherlock 独立性:不需要ActionBarSherlock等支持库
- Customization: Easy to change colors and menus 定制:易于更改颜色和菜单
What's New 什么是新的
- Changed the sliding animation to match Facebook and Google+ apps 更改了滑动动画以匹配Facebook和Google+应用
- Added standard ActionBar (you can chose to use ActionBarSherlock) 添加标准ActionBar(您可以选择使用ActionBarSherlock)
- Used menuitem to open the Menu 使用menuitem打开菜单
- Added ability to update ListView on main Activity 添加了在主Activity上更新ListView的功能
- Added 2 ListViews to the Menu, similiar to Facebook and Google+ apps 在菜单中添加了2个ListView,类似于Facebook和Google+应用程序
- Added a AutoCompleteTextView and a Button as well to show examples of implemenation 添加了AutoCompleteTextView和Button以显示实现示例
- 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! 与Facebook和Google+应用程序不同,允许用户同时与后台(主ListView)和菜单进行交互!
ActionBar with Menu out 带菜单的ActionBar

ActionBar with Menu out and search selected 选择了菜单输出和搜索的ActionBar

#4楼 Personally I like the navigationDrawer in Google Drive official app. 我个人喜欢Google Drive官方应用中的navigationDrawer 。 It just works and works great. 它只是工作和工作很好。 I agree that the navigation drawer shouldn't move the action bar because is the key point to open and close the navigation drawer. 我同意导航抽屉不应移动操作栏,因为它是打开和关闭导航抽屉的关键点。
If you are still trying to get that behavior I recently create a project Called SherlockNavigationDrawer and as you may expect is the implementation of the Navigation Drawer with ActionBarSherlock and works for pre Honeycomb devices. 如果您仍在尝试获取该行为,我最近创建了一个名为SherlockNavigationDrawer 的项目,您可能期望使用ActionBarSherlock 实现导航抽屉,并适用于蜂窝前设备。 Check it: 核实:
SherlockNavigationDrawer github SherlockNavigationDrawer github
#5楼 There is a great implementation of NavigationDrawer that follows the Google Material Design Guidelines (and compatible down to API 10) - The MaterialDrawer library (link to GitHub) . 有一个很棒的NavigationDrawer 实现遵循Google Material Design Guidelines(兼容到API 10) - MaterialDrawer库(链接到GitHub) 。 As of time of writing, May 2017, it's actively supported. 截至2017年5月,它已得到积极支持。
It's available in Maven Central repo . 它可以在Maven Central repo中找到 。 Gradle dependency setup: Gradle依赖设置:
compile 'com.mikepenz:materialdrawer:5.9.1'
Maven dependency setup: Maven依赖设置:
<dependency>
<groupId>com.mikepenz</groupId>
<artifactId>materialdrawer</artifactId>
<version>5.9.1</version>
</dependency>
 
#6楼我知道这是一个老问题,但最新的答案是使用Android支持设计库 ,让您的生活更轻松。 |