Android 如何创建带有菜单项的滑动抽屉?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12027980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can i create a sliding drawer with menu items?
提问by Mridang Agarwalla
How can I create a horizontal sliding drawer like the YouTube and Facebook app has.
如何创建像 YouTube 和 Facebook 应用程序那样的水平滑动抽屉。
Many other apps seem to use use the same style, so I'm guessing that this is a part of the default Androind UI framework but I can't seem to piece it together.
许多其他应用程序似乎使用相同的样式,所以我猜这是默认 Androind UI 框架的一部分,但我似乎无法将它拼凑在一起。
You can see some more samples here.
您可以在此处查看更多示例。
Thanks.
谢谢。
回答by Ahmad
This is a sliding menu, you can implement this by writing a custom view. There are a lot of good open source examples. I would recommend you to use thisone.
这是一个滑动菜单,您可以通过编写自定义视图来实现。有很多很好的开源示例。我建议你使用这个。
You can use it by defining this in your Layout:
您可以通过在布局中定义它来使用它:
<com.slidingmenu.lib.SlidingMenu
xmlns:sliding="http://schemas.android.com/apk/res-auto"
android:id="@+id/slidingmenulayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
sliding:viewAbove="@layout/YOUR_ABOVE_VIEW"
sliding:viewBehind="@layout/YOUR_BEHIND_BEHIND"
sliding:touchModeAbove="margin|fullscreen"
sliding:touchModeBehind="margin|fullscreen"
sliding:behindOffset="@dimen/YOUR_OFFSET"
sliding:behindWidth="@dimen/YOUR_WIDTH"
sliding:behindScrollScale="@dimen/YOUR_SCALE"
sliding:shadowDrawable="@drawable/YOUR_SHADOW"
sliding:shadowWidth="@dimen/YOUR_SHADOW_WIDTH" />
Edit:
编辑:
The Android team introduced an official sliding pattern on Google IO 2013. Read everything about it here.
Android 团队在 Google IO 2013 上引入了官方滑动模式。在此处阅读有关它的所有内容。
回答by Pieces
As far as I know it is not part of the default framework. This is the only place I can find it mention in the Android docs http://developer.android.com/design/patterns/actionbar.htmland I have search quite a bit.
据我所知,它不是默认框架的一部分。这是我在 Android 文档http://developer.android.com/design/patterns/actionbar.html 中唯一能找到它提到的地方,我进行了大量搜索。
This so far has been my favorite library https://bitbucket.org/verdigo/drawer/straight forward and easy to use.
到目前为止,这一直是我最喜欢的库https://bitbucket.org/verdigo/drawer/直接且易于使用。
Also pretty recently HoloEverywhere library added a drawer you can use. This one interests me since I use HoloEverywhere in most of my apps and it looks very similar to Foursquares. https://github.com/Prototik/HoloEverywhere
最近 HoloEverywhere 库还添加了一个可以使用的抽屉。我对这个很感兴趣,因为我在大多数应用程序中都使用 HoloEverywhere,它看起来与 Foursquares 非常相似。 https://github.com/Prototik/HoloEverywhere
回答by bCliks
How can I create a horizontal sliding drawer like the YouTube and Facebook app has.
FYI: These are not sliding drawer. That is Navigation Drawer. You can create a Navigation drawer by following this sample project.