Android沉浸式状态栏、导航栏
2015-10-23 18:52
471 查看
Android沉浸式状态栏,用的是开源库SystemBarTint。
demo下载地址:http://download.csdn.net/download/shenyuanqing/9226623
效果图:
依次(Android5.0及以上)->(Android4.4及以上)->(Android4.4以下)
步骤:
1.添加类SystemBarTintManager到项目中
2.添加代码
3.XML最外层布局加下面属性,不然会有什么情况自己对比下就知道了
demo下载地址:http://download.csdn.net/download/shenyuanqing/9226623
效果图:
依次(Android5.0及以上)->(Android4.4及以上)->(Android4.4以下)
步骤:
1.添加类SystemBarTintManager到项目中
2.添加代码
//Android4.4及以上版本才能设置此效果 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //Android5.0版本 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS | WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); //设置状态栏颜色 getWindow().setStatusBarColor(getResources().getColor(R.color.green)); //设置导航栏颜色 getWindow().setNavigationBarColor(getResources().getColor(R.color.green)); }else { //透明状态栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); //透明导航栏 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); //创建状态栏的管理实例 SystemBarTintManager tintManager = new SystemBarTintManager(this); //激活状态栏设置 tintManager.setStatusBarTintEnabled(true); //设置状态栏颜色 tintManager.setTintResource(R.color.green); //激活导航栏设置 tintManager.setNavigationBarTintEnabled(true); //设置导航栏颜色 tintManager.setNavigationBarTintResource(R.color.green); } }
3.XML最外层布局加下面属性,不然会有什么情况自己对比下就知道了
android:fitsSystemWindows="true"
相关文章推荐
- ViewPager图片轮播
- Android Notification详解——响应notification事件
- Android Studio 混淆出现can't find referenced method 的解决方法
- android 版本在线更新
- Android内存泄漏检测-LeakCanary
- 学习笔记_Android之常见四种点击事件的实现方法
- Android控件:自定义View和ViewGroup相关
- Ant自动编译打包&发布 android项目
- Android控件默认风格解析之SeekBar
- Android 动态加载 APK
- android studio 更改背景和设置字体大小
- android 沉浸式状态栏(像ios那样的状态栏与应用统一颜色样式)
- android Matrix图片随意的放大缩小,拖动
- 命令行从Android手机中导出已安装APK的方法调研
- android中handler用法总结
- android中通知系统扫描系统媒体文件的几种方法
- android关于data/data/目录下,各应用之间的私有数据读写
- Android - Design Support Library 学习总结 2
- Android开发 关于软键盘的 打开与关闭
- android系统编译记录