android沉浸式状态栏

1.代码中动态设置

if(VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
//透明状态栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//透明导航栏
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}

当有 actionbar 父布局添加如下:

    android:fitsSystemWindows="true"
    android:clipToPadding="true"
  1. 在 Manifest 配置文件 them设置
@android:style/Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor  @android:style/Theme.Holo.Light.NoActionBar.TranslucentDecor        @android:style/Theme.Holo.NoActionBar.TranslucentDecor

开源项目有。
https://github.com/jgilfelt/SystemBarTint

你可能感兴趣的:(android沉浸式状态栏)