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. Android中TextVIew一些属性
  2. Android将ListView逆时针旋转90°实现横向滑动
  3. Android(安卓)统计图表引擎AChartEngine(四) - 源码示例 嵌入Aci
  4. Android系统中设置TextView的行间距(非行高)
  5. Android中ListView学习---你可能不知道的细节
  6. Android中使用Dialog风格弹出框的Activity
  7. katalon设置Android(安卓)SDK路径
  8. Android(安卓)ApiDemos示例解析(15):App->Activity->SetWallpaper
  9. Android(安卓)Studio使用手册

随机推荐

  1. 如何使用与相同文件运行的命令更新文件?
  2. Linux安装ElasticSearch-2.2.0-分词器插
  3. 解决useradd 用户后没有添加用户Home目录
  4. 【RFB】Linux uinput 分析,虚拟鼠标,键盘
  5. Red Hat Linux下如何修改网卡MAC地址
  6. window下使用vnc远程登录linux图形界面和
  7. Linux源码包里有个scripts文件夹,里面放的
  8. linux驱动之分离分层的概念
  9. 在两台Linux机器之间配置一条SLIP链路,以
  10. linux下mysql表名大小写敏感问题