You can use this class for fullscreen Activity
where status and navigation view does not bleed into NavigationView.
I had the same problem and tried the combination of system flags and found the right combination.
// Removes bleeding transparency onto navigation-view
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
Here is my fullscreen Activity.
public class FullScreenAppCompatActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT < 14) {
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
} else {
hideSystemUI();
}
}
/*
* ************ SETTING FULLSCREEN TRANSITIONS ************
*/
/**
* Hide Status and Navigation bars
*/
@SuppressLint("InlinedApi")
public void hideSystemUI() {
View decorView = getWindow().getDecorView();
// Hide both the navigation bar and the status bar.
// SYSTEM_UI_FLAG_FULLSCREEN is only available on Android 4.1 and
// higher, but as
// a general rule, you should design your app to hide the status bar
// whenever you
// hide the navigation bar.
// Navigation bar hiding: Backwards compatible to ICS.
// SELECTIVE FLAGS final code: 5890
// setSelectedFlags(decorView);
// NO SELECTION OF SDK_INT flag final cod: 5894
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// Views can use nav bar space if set
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
// Navigation bar hiding: Backwards compatible to ICS.
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// Status bar hiding: Backwards compatible to Jellybean
| View.SYSTEM_UI_FLAG_FULLSCREEN
// Immersive mode: Backward compatible to KitKat.
// Note that this flag doesn't do anything by itself, it only
// augments the behavior
// of HIDE_NAVIGATION and FLAG_FULLSCREEN. For the purposes of
// this sample
// all three flags are being toggled together.
// Note that there are two immersive mode UI flags, one of which
// is referred to as "sticky".
// Sticky immersive mode differs in that it makes the navigation
// and status bars
// semi-transparent, and the UI flag does not get cleared when
// the user interacts with
// the screen.
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
// Removes bleeding transparency onto navigation-view
getWindow().addFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
private void setSelectedFlags(View decorView) {
int selectedFlags = 0;
if (Build.VERSION.SDK_INT >= 14) {
selectedFlags ^= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
Toast.makeText(getApplicationContext(), "View.SYSTEM_UI_FLAG_HIDE_NAVIGATION flag " + selectedFlags,
Toast.LENGTH_SHORT).show();
}
// Status bar hiding: Backwards compatible to Jellybean
if (Build.VERSION.SDK_INT >= 16) {
selectedFlags ^= (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
// Views can use nav bar space if set
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
Toast.makeText(getApplicationContext(), "View.SYSTEM_UI_FLAG_FULLSCREEN flag " + selectedFlags,
Toast.LENGTH_SHORT).show();
}
if (Build.VERSION.SDK_INT >= 19) {
selectedFlags ^= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
}
Toast.makeText(getApplicationContext(), "Final SELECTED flag " + selectedFlags, Toast.LENGTH_SHORT).show();
decorView.setSystemUiVisibility(selectedFlags);
int currentVisibility = getWindow().getDecorView().getSystemUiVisibility();
Toast.makeText(getApplicationContext(), "Initial visibility flag " + currentVisibility, Toast.LENGTH_SHORT)
.show();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
}
}
}
Android Emulator
. You can check this on yourPhysical Device
– Prefer