具体使用原生沉浸式可以参照郭霖大神文章
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);
}