Systembartint 的使用

具体使用原生沉浸式可以参照郭霖大神文章
http://blog.csdn.net/guolin_blog/article/details/51763825

Systembartint Github下载地址:https://github.com/jgilfelt/SystemBarTint

1. 基本介绍

应用背景着色Android系统UI当使用KitKat半透明的模式。

这里写图片描述

Android 4.4(KitKat)介绍了半透明的系统UI样式地位和导航栏。
这些风格的壁纸的基础活动,比如主屏幕发射器,但提供的最低背景保护使他们更有用的其他类型的活动,除非你提供自己的背景在你的 这个库提供了一个简单的方法来创建一个背景系统的“色彩”酒吧,无论是颜色值或可移动。 默认情况下它会给你一种半透明的黑色背景,将用于全出血屏幕持续系统UI内容仍然是重要的——比如当放置在地图或照片网格。 添加三方类库

compile 'com.readystatesoftware.systembartint:systembartint:1.0.3'

这里写图片描述

3. 修改application中继承的Style样式

这里写图片描述

4. 具体用法

/**
* api KitKat特定的半透明效果.
*/
private void applyKitKatTranslucency() {

    // KitKat translucent navigation/status bar.
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setTranslucentStatus(true);
        SystemBarTintManager mTintManager = new SystemBarTintManager(this);
        mTintManager.setStatusBarTintEnabled(true);

        mTintManager.setStatusBarTintResource(R.color.title_bg);//通知栏所需颜色
    }

}

/**
* 设置高低版本的兼容
* @param on
*/
@TargetApi(19)
private void setTranslucentStatus(boolean on) {
    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);
}

5. 运行效果

这里写图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值