How can I do permanently fullScreen app on Java

65 Views Asked by At

I made the application full screen with the following code block. But when user scrolls from top to bottom, notification bar and nav bar appear. How can I completely prevent this?

requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // Tam ekran yap
        View decorView = getWindow().getDecorView();
        int uiOptions = View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
        decorView.setSystemUiVisibility(uiOptions);
2

There are 2 best solutions below

1
Harshil Thakkar On

You might have to change your Java class accordingly little bit.

If you want to remove status bar too then use this before setContentView(layout) in onCreateView method

 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
    WindowManager.LayoutParams.FLAG_FULLSCREEN);
1
Rahul Routh On

Just Used these 2 lines of code inside onCreate

Window window = getWindow();
WindowCompat.setDecorFitsSystemWindows(window,false);
    
//Night mode off (Only used when you are off Night mode in apps)
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);