新的Facebook应用程序和它的导航太酷了。我只是想看看如何在我的应用程序中模仿它。
有人知道怎么实现吗?
点击左上角按钮,页面滑动,显示如下画面:
YouTube视频
新的Facebook应用程序和它的导航太酷了。我只是想看看如何在我的应用程序中模仿它。
有人知道怎么实现吗?
点击左上角按钮,页面滑动,显示如下画面:
YouTube视频
当前回答
作为我的Android公共库(ACL)的一部分,我实现了自己的侧边栏。 主要优点:
侧栏可以设置为任何位置:左,上,下,右 主视图和滑动视图都是可点击的 侧栏可以部分显示 侧边栏的可样式属性更容易更改它的样式 maven回购中的神器 一个大图书馆的一部分
源代码:https://github.com/serso/android-common/tree/master/views/src/main/java/org/solovyev/android/view/sidebar
用法:https://github.com/serso/android-common/blob/master/samples/res/layout/acl_view_layout.xml
其他回答
对于信息,因为兼容性库开始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.
这是一种方法,我希望我讲得够清楚了。
这是另一个lib,在我看来似乎是最好的。不是我写的。
更新:
这段代码似乎最适合我,它移动整个动作栏类似于G+应用程序。
谷歌是如何做到这一点的?在Android应用程序中滑动动作栏
作为我的Android公共库(ACL)的一部分,我实现了自己的侧边栏。 主要优点:
侧栏可以设置为任何位置:左,上,下,右 主视图和滑动视图都是可点击的 侧栏可以部分显示 侧边栏的可样式属性更容易更改它的样式 maven回购中的神器 一个大图书馆的一部分
源代码:https://github.com/serso/android-common/tree/master/views/src/main/java/org/solovyev/android/view/sidebar
用法:https://github.com/serso/android-common/blob/master/samples/res/layout/acl_view_layout.xml
Android增加了导航栏。请参考这个
link
我自己也玩过这个,我能找到的最好的方法是使用FrameLayout,并在菜单顶部放置一个自定义的HorizontalScrollView (HSV)。在HSV内部是应用程序视图,但是有一个透明的视图作为第一个子视图。这意味着,当HSV有零滚动偏移时,菜单将显示(并且仍然是可点击的)。
当应用程序启动时,我们将HSV滚动到第一个可见应用程序视图的偏移量,当我们想要显示菜单时,我们向后滚动以通过透明视图显示菜单。
代码在这里,底部的两个按钮(称为HorzScrollWithListMenu和HorzScrollWithImageMenu)在启动活动中显示了我能想出的最好的菜单:
Android滑动菜单演示
模拟器截图(中间滚动):
来自设备的截图(全滚动)。注意,我的图标没有Facebook菜单图标宽,所以菜单视图和“应用程序”视图并不对齐。