reference to : http://blog.csdn.net/chencehnggq/article/details/21492417
activity.java
mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar.setTitle(getResources().getString(R.string.app_name)); mToolbar.setTitleTextColor(getResources().getColor(R.color.common_white)); setSupportActionBar(mToolbar); ActionBarDrawerToggle mDrawerToggle = new ActionBarDrawerToggle( this, mDrawerLayout, mToolbar, R.string.app_name, R.string.app_name ); mDrawerLayout.addDrawerListener(mDrawerToggle); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mDrawerToggle.syncState();
public void onBackPressed() { if (!mDrawerLayout.isDrawerOpen(mLeftMenu)) { mDrawerLayout.openDrawer(mLeftMenu); } else { super.onBackPressed(); } }
styles.xml
<!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="android:windowBackground">@android:color/white</item> <item name="drawerArrowStyle">@style/DrawerArrowStyle</item> </style> <style name="DrawerArrowStyle" parent="Widget.AppCompat.DrawerArrowToggle"> <item name="spinBars">true</item> <item name="color">@android:color/white</item> </style>
分类: Android Pro
本文转自demoblog博客园博客,原文链接http://www.cnblogs.com/0616--ataozhijia/p/5955560.html如需转载请自行联系原作者
demoblog