[Android Pro] ActionBarDrawerToggle 使用小结

reference to  : http://blog.csdn.net/chencehnggq/article/details/21492417

activity.java

[Android Pro] ActionBarDrawerToggle 使用小结
        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();
[Android Pro] ActionBarDrawerToggle 使用小结
[Android Pro] ActionBarDrawerToggle 使用小结
    public void onBackPressed() {
        if (!mDrawerLayout.isDrawerOpen(mLeftMenu)) {
            mDrawerLayout.openDrawer(mLeftMenu);
        } else {
            super.onBackPressed();
        }
    }
[Android Pro] ActionBarDrawerToggle 使用小结

styles.xml

[Android Pro] ActionBarDrawerToggle 使用小结
<!-- 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] ActionBarDrawerToggle 使用小结

 

分类: Android Pro
本文转自demoblog博客园博客,原文链接http://www.cnblogs.com/0616--ataozhijia/p/5955560.html如需转载请自行联系原作者

demoblog
上一篇:线程同步锁的选择


下一篇:js字符串编码方法总结