Android沉浸式状态栏

市场上,现阶段很流行Android沉浸式开发,但是限于google api的限制,所以此特性只能针对Android4.4,Github上目前开源的SystemBarTint能够很好的实现此特性。

沉浸式实现

Android 4.4 特有属性,Android 5.0以上机型,默认开启。

1:利用Android studio 导入 jar 包

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

2:使用SytemBarTintManager

protected void setSystemBarTintDrawable(Drawable d) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            SystemBarTintManager mTintManager = new SystemBarTintManager(this);            if (d != null) {                mTintManager.setStatusBarTintEnabled(true);                mTintManager.setTintDrawable(d);            } else {                mTintManager.setStatusBarTintEnabled(false);                mTintManager.setTintDrawable(null);            }       } }

3:设置状态栏透明

  /**     * set status bar translucency     * @param on     */    protected void setTranslucentStatus(boolean on) {        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {            Window win = getWindow();            WindowManager.LayoutParams winParams = win.getAttributes();            final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;            if (on) {                winParams.flags |= bits;            } else {                winParams.flags &= ~bits;            }            win.setAttributes(winParams);        }    }

4:设置完成

5:温馨提示:

[DEPRECATED] Apply background tinting to the Android system UI when using KitKat translucent modes.

SystemBarTint上已经不支持使用该jar了。

更多相关文章

  1. 有关Material Design新特性的详解。
  2. 我使用过的 控件的一些特性(layout_weight,paddingleft)
  3. android 5.0新特性
  4. Android M5 新特性
  5. 2012版辅助开发工具包(ADT)新功能特性介绍及安装使用
  6. android和ios的系统特性区别
  7. Android Studio3.0新特性及安装图文教程
  8. android 5.0 新特性
  9. android studio 3.6.0 绑定视图新特性

随机推荐

  1. (lintcode)第29题交叉字符串
  2. (lintcode)第13题字符串的查找
  3. (lintcode)第336题斐波那契数列
  4. 懒加载作业
  5. 进程与线程 - 入门知识篇
  6. SpringBoot中的自动代码生成 - 基于Mybat
  7. rsync实现服务器数据同步备份
  8. NoSQL Memcached
  9. 2018年5大微服务发展趋势
  10. 堡垒机介绍