标签:android material design drawer layout actionbardrawertoggl
实际上,官方已经提供了实现方法,但是,有很多捞偏门的教程,也有很优秀的第三方。写出来,供还没找到的同学参考。
前提是:你对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);
这还没有结束,必须有以下代码才能实现旋转动画:
@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的旋转箭头的实现方式。
标签:android material design drawer layout actionbardrawertoggl
原文地址:http://blog.csdn.net/boybeak/article/details/44228493