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"
- 在 Manifest 配置文件 them设置
@android:style/Theme.DeviceDefault.Light.NoActionBar.TranslucentDecor @android:style/Theme.Holo.Light.NoActionBar.TranslucentDecor @android:style/Theme.Holo.NoActionBar.TranslucentDecor