状态栏 ActionBar 导航栏隐藏

欧阳元魁
2023-12-01

1,隐藏状态栏 导航栏

if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) {
    View v = this.getWindow().getDecorView();
    v.setSystemUiVisibility(View.GONE);
} else if (Build.VERSION.SDK_INT >= 21) {
    View decorView = getWindow().getDecorView();
    int uiOptions =
            View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                    | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                    | View.SYSTEM_UI_FLAG_FULLSCREEN
                    | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                    |View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);
    getWindow().setStatusBarColor(Color.TRANSPARENT);
}

2,隐藏actionBar,在application添加style

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.AppCompat.Light.NoActionBar">
 类似资料: