在style样式里面添加如下item (位置 : res/values/styles.xml)

 true        true

完整的代码如下


  注意此時的狀態欄不占用位置還需要在樣式中添加如下配置

name="android:fitsSystemWindows">true


然后在BaseActivity的onCreate方法中调用如下方法

private void initSystemBar() {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            SystemBarTintManager tintManager = new SystemBarTintManager(this);            tintManager.setStatusBarTintEnabled(true);// Holo light action bar color is #DDDDDD            int actionBarColor = Color.parseColor("#1a92fe");            tintManager.setStatusBarTintColor(actionBarColor);        }    }


这里用的用一个开源库

地址:https://github.com/jgilfelt/SystemBarTint


需要在build.gradle中添加


dependencies {    compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'}





更多相关文章

  1. Android获取桌面启动图标的位置
  2. 【Java】从内部类中访问变量,需要声明为final
  3. Android位置服务--用户定位Location
  4. [Android]获取设备IP地址
  5. Android(安卓)Studio 3.0+添加ButterKnife依赖报错的解决办法
  6. android 关于使用retrofit2.0的一些问题
  7. Android(安卓)2.2 r1 API中文文档—— Toast
  8. Android(安卓)Studio配置AspectJ(使用jar包的方法)
  9. 使用ViewServer让Android真机可用HierarchyView视图检测工具

随机推荐

  1. 【Android(安卓)开发教程】经过预定义的
  2. android屏幕单位
  3. 查看基于Android(安卓)系统单个进程内存
  4. android 开发学习笔记 (一)
  5. android 创建数字签名应用程序
  6. "Uses or overrides a deprecated API" i
  7. android 多版本打包之productFlavors 用
  8. Android(java)学习笔记126:Android(安卓)Stu
  9. Android(安卓)中的单元测试(使用AndroidT
  10. Android深入浅出系列课程---Lesson9 AAF1