ActionBarDrawerToggle
来源:互联网 发布:算法导论 第四版 mobi 编辑:程序博客网 时间:2024/06/06 04:11
ActionBarDrawerToggle 是 DrawerLayout.DrawerListener实现。和 NavigationDrawer 搭配使用,推荐用这个方法,符合Android design规范。
作用:
- 改变android.R.id.home返回图标。
- Drawer拉出、隐藏,带有android.R.id.home动画效果。
- 监听Drawer拉出、隐藏
DrawerLayout.DrawerListener这个接口提供了回调抽屉事件, 如onDrawerOpened()和onDrawerClosed (),ActionBarDrawerToggle实现了DrawerLayout.DrawerListener. 所以你仍然可以覆盖这些回调, 但它也有助于正确的交互行为, 在工具栏的图标和导航抽屉之间。它的构造方法, 这就需要以下参数:
- 持有抽屉的Activity.
- DrawerLayout对象.
- 一个Drawable资源作为抽屉指示器.
- 字符串资源描述”打开抽屉”动作.
- 字符串资源描述”关闭抽屉”动作.
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
ps:貌似这个ActionBarDrawerToggle原来是在android.support.v4.app包下,现在换到了android.support.v7.app这个包。也就是v7包。值得注意的是,然后它的构造方法是有变化的,上边的例子使用的就是v7包中的ActionBarDrawerToggle,我们来看一下他的构造方法是怎么定义的:
public ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, @StringRes int openDrawerContentDescRes, @StringRes int closeDrawerContentDescRes) {………… }
与原来的相比,这个里面多加了一个 ToolBar 的参数,因为我没有用过v4包中的ActionBarDrawerToggle,具体这里有什么变化还需要日后的研究。
0 0
- ActionBarDrawerToggle
- ActionBarDrawerToggle
- ActionBarDrawerToggle 使用小结
- ActionBarDrawerToggle 使用小结
- ActionBarDrawerToggle 使用小结
- ActionBarDrawerToggle 被废弃 -- Deprecated
- ActionBarDrawerToggle is Deprecated
- 处理 ActionBarDrawerToggle is Deprecated
- ActionBarDrawerToggle is Deprecated
- ActionBarDrawerToggle与DrawerLayout
- ActionBarDrawerToggle的onOptionsItemSelected方法
- DrawerLayout与ActionBarDrawerToggle使用
- ActionBarDrawerToggle的使用
- Android ActionBarDrawerToggle、DrawerLayout、ActionBar 结合
- Android ActionBarDrawerToggle、DrawerLayout、ActionBar 结合
- Android ActionBarDrawerToggle、DrawerLayout、ActionBar 结合
- Android ActionBarDrawerToggle、DrawerLayout、ActionBar 结合
- ActionBarDrawerToggle和ToolBar结合使用
- 学习整理——Java类初始化顺序
- 十个热门开源深度学习框架
- QCustomPlot的replot效率
- 笔记--Activity
- SpringMvc前端提交多个对象,后台接收
- ActionBarDrawerToggle
- QLabel 显示图片
- 高斯差分有什么用
- Django数据库操作
- tomcat 项目维护
- 求各种进制下,各位数之和的平均值
- 自定义控件三部曲之绘图篇(十二)——Paint之setXfermode(三)
- 浏览器兼容问题
- 设计模式之单例模式