码迷,mamicode.com
首页 > 其他好文 > 详细

Material DesignDrawerLayout的旋转箭头的实现方式。

时间:2017-08-19 16:59:14      阅读:98      评论:0      收藏:0      [点我收藏+]

标签:after   raw   err   term   箭头   sso   protected   pos   技术分享   

实际上,官方已经提供了实现方法,可是,有非常多捞偏门的教程,也有非常优秀的第三方。写出来。供还没找到的同学參考。


前提是:你对android.support.v7.widget.Toolbar已经有过了解了。

mMainBar = (Toolbar)this.findViewById(R.id.main_bar);
this.setSupportActionBar(mMainBar);
mDrawerLayout = (DrawerLayout)this.findViewById(R.id.main_drawer_layout);
mToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mMainBar, R.string.app_name, R.string.hello_world);
mDrawerLayout.setDrawerListener(mToggle);

以上是在onCreate里要做的事。注意:此时的ActionBarDrawerToggle不是v4包中的。而是android.support.v7.app.ActionBarDrawerToggle;这是关键。

这还没有结束,必须有下面代码才干实现旋转动画:

@Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // Pass any configuration change to the drawer toggls
        mToggle.onConfigurationChanged(newConfig);
    }

技术分享

Material DesignDrawerLayout的旋转箭头的实现方式。

标签:after   raw   err   term   箭头   sso   protected   pos   技术分享   

原文地址:http://www.cnblogs.com/yutingliuyl/p/7396694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!