新的Facebook应用程序和它的导航太酷了。我只是想看看如何在我的应用程序中模仿它。
有人知道怎么实现吗?
点击左上角按钮,页面滑动,显示如下画面:
YouTube视频
新的Facebook应用程序和它的导航太酷了。我只是想看看如何在我的应用程序中模仿它。
有人知道怎么实现吗?
点击左上角按钮,页面滑动,显示如下画面:
YouTube视频
当前回答
下面是官方android文档中的设计和开发指南,不需要添加非官方的外部库。只有android支持库可以做到。在这里找到链接。
设计和开发。
其他回答
我刚刚为我自己的项目实现了类似的视图。你可以在这里查看
下面是基于我写的库的示例应用程序的屏幕:
使用这个自定义视图作为XML布局的元素是很容易的。这里有一个例子:
<shared.ui.actionscontentview.ActionsContentView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:actions_layout="@layout/actions"
app:content_layout="@layout/content" />
如果你对ActionsContentView库的使用有任何疑问,我可以在项目Wiki上写一篇小文章。
这个库的一些优点:
通过触摸滑动视图的能力 在XML中很容易调整动作栏的大小 支持2.0及以上的所有Android SDK版本
但有一个限制:
所有水平滚动视图都不能在此视图的边界上工作
最好的问候, 史蒂文
我认为facebook应用程序不是用原生代码(我指的是在Android中使用布局的原生代码)编写的,但他们使用了webview,并使用了一些javascript ui库,如sencha。使用sencha框架可以很容易地实现。
对于信息,因为兼容性库开始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.
这是一种方法,我希望我讲得够清楚了。
下面是官方android文档中的设计和开发指南,不需要添加非官方的外部库。只有android支持库可以做到。在这里找到链接。
设计和开发。
这是另一个lib,在我看来似乎是最好的。不是我写的。
更新:
这段代码似乎最适合我,它移动整个动作栏类似于G+应用程序。
谷歌是如何做到这一点的?在Android应用程序中滑动动作栏