[Android Pro] ActionBarDrawerToggle 使用小结
Android 小结 Pro 使用
2023-09-14 08:56:59 时间
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 studio 报错 The specified Android SDK Build Tools version (27.0.3) is ignored, as it is below the minimum supported version (28.0.3) for Android Gradle
- [Android] Android统计Apk , jar包方法数
- [Android Pro] android 杀死进程的方法
- [Android Pro] ant 编译android工程
- android Universal Image Loader for Android 说明文档 (1)
- 《android开发艺术探索》读书笔记(十五)--Android性能优化
- Android报错提示:Failed to resolve: com.android.support.constraint:constraint-layout:1.1.3
- Android 9.0 遥控器点击输入框 弹不出输入法
- Android 9.0 延时开机动画解决首次开机黑屏和去掉android正在启动的提示框
- Android 10.0 Sdcard预留一部分空间(500M)
- Android ContentProvider根据URI修改某行某列的值
- 【Android Gradle 插件】ProductFlavor 配置 ( AppExtension#externalNativeBuild 配置 | cmake 配置 | ndkBuild 配置 )
- Android之解压缩ramdisk文件系统(一百三十二)
- Android - 控件android:ems属性
- Android的报错提示:Failed to resolve: com.android.support:appcompat-v7:28.0.0
- Android App版本更新知识总结