Bri*_*der 9 navigation android drawer android-actionbar-compat
我开始使用ActionBarSherlock使用NavigationDrawer并获得了很好的结果,但我的公司批准这个开源很可能不会很快到来,所以我正在努力切换到ActionBarCompat.
ActionBarCompat昨天(2013年7月24日)正式发布.有没有人让两个人都很好地相处?我希望我能回答我自己的问题,但看看是否有人让这个问题起作用.比赛开始了!:-)
YouTube上的ActionBarCompat发布: https ://www.youtube.com/watch?v = 6TGgYqfJnyc
更新(工作代码,是的!): 我已经从Google转换为使用ActionBarCompat的示例NavigationDrawer应用程序,它运行正常.您可以在此处找到它作为参考或开始您的项目:https: //github.com/bcrider/NavigationDrawerActionBarCompat
2.x版本看起来比使用ActionBarSherlock的方式更好,但是我必须更多地使用ActionBarCompat来看看我是否更喜欢它.
Bri*_*der 13
注意:我太新了,不能在帖子等中添加多个链接,所以我回答我自己的问题而不是编辑它(希望不违反规则?).一旦允许就会编辑原文.
使用ActionBarCompat添加导航抽屉的简单方法: 我发现转换现有的应用程序并不像我想象的那么糟糕.谷歌的样本让我相信片段是必需的,但事实并非如此......远非如此.
您可以使用DrawerLayout简单地包装现有布局,并插入ListView(或任何包含ListView的布局)以进行实际导航.然后将正常代码添加到现有的Activity(扩展ActionBarActivity)并构建导航,无论如何都要如此.
下面是一些用于包装现有布局的示例代码:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
[YOUR EXISTING LAYOUT GOES HERE]
<ListView
android:id="@+id/left_drawer"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)
如果你想从一个使用片段并从那里开始的示例应用程序开始,这里是基于示例代码的我的github存储库:https://github.com/bcrider/NavigationDrawerActionBarCompat
| 归档时间: |
|
| 查看次数: |
5853 次 |
| 最近记录: |