新的Facebook应用程序和它的导航太酷了。我只是想看看如何在我的应用程序中模仿它。

有人知道怎么实现吗?

点击左上角按钮,页面滑动,显示如下画面:

YouTube视频


当前回答

2012年6月,谷歌在Eclipse ADT插件中添加了“模板”,有一个称为“主/细节流”的模板,它正是这样做的(基于片段)。

其他回答

我在过去的几天里一直在玩这个,我已经提出了一个解决方案,这是相当直接的,在pre-Honeycomb。我的解决方案是动画我想要滑动的视图(FrameLayout为我),并监听动画的结束(在这一点上抵消视图的左/右位置)。我在这里粘贴了我的解决方案:如何动画一个视图的翻译

我用AbsoluteLayout和一个简单的滑动控制器实现了这一点,它可以将视图移动到一个负偏移来隐藏。

如果有人感兴趣,我可以清理代码/布局和发布。我知道AbsoluteLayout被弃用了,但它是一个非常直接的实现。左视图/右视图,当“滑动打开”时,只需将左视图从- x偏移量移出到设备的宽度-任何你想显示的右视图

我在上面的回答中没有看到令人惊叹的SimonVT/android-menudrawer。这里有一个链接

https://github.com/SimonVT/android-menudrawer

它非常容易使用,你可以把它放在左边,右边,上面或下面。非常好的文档,包括示例代码和Apache 2.0许可证。

不能评论@Paul Grime给出的答案,无论如何,我已经在他的github项目上提交了闪烁问题的修复....

我会在这里发布修正,也许有人需要它。您只需要添加两行代码。动画下面的第一个。setAnimationListener电话:

anim.setFillAfter(true);

在app.layout()调用之后的第二个函数:

app.clearAnimation();

希望这对你有所帮助。

对于信息,因为兼容性库开始1.6和这个facebook应用程序也运行在设备与Android 1.5,它不能用碎片。

The way you could do it, is : Create a "base" activity BaseMenuActivity where you put all the logic for the onItemClickListener for your menu list and defines the 2 animation ("open" and "close"). At the end/beginning of the animations, you show/hide the layout of the BaseMenuActivity (lets call it menu_layout). The layout for this activity is simple, its only a list with items + a transparent part at the right of your list. This part will be clickable and its width will be the same width as your "move button". With that, you'll be able to click on this layout to start the animation to let the content_layout slide to the left and take the whole screen. For each option (i.e. item of the menu list), you create a "ContentActivity" which extends the BaseMenuActivity. Then when you click on an item of the list, you start your ItemSelectedContentActivity with the menu visible (which you'll close as soon as your activity starts). The layouts for each ContentActivity are FrameLayout and includes the and . You just need to move the content_layout and make the menu_layout visible when you want.

这是一种方法,我希望我讲得够清楚了。