title: How to make full screen without system bars for showing splash screen?
body: <p>I am trying to make a full screen without system bars as my splash screen but I have some problems with resizing my root layout when my application starts.</p>
  <p>I do not have any problem with a bottom because my root layout resizes behind the navigation bar and goes to the end of the screen what I actually wanted to do.
  The problem is with the top side of the root layout because it doesn't go to the top of the screen. On the top of my screen, I have black empty space which is left after I hide the status bar.</p>
  <p>NOTE: Im using  minSdkVersion 22 and targetSdkVersion 29.</p>
  <p>For demonstration purposes, I will use simple code with one activity and one corresponding XML layout file with green background and 2 buttons within the Constraint Layout as root layout.</p>
  <p>MainActivity:</p>
  <pre><code>package com.systemwindowexercise
  
  import androidx.appcompat.app.AppCompatActivity
  import android.os.Bundle
  import android.view.*
  
  class MainActivity : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
  
          window.navigationBarColor = resources.getColor(R.color.translucent)
          window.statusBarColor = resources.getColor(R.color.translucent)
  
          window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                  or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                  or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                  or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                  or View.SYSTEM_UI_FLAG_FULLSCREEN)
  
      }
  
  }
  </code></pre>
  <p>activity_main:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:id=&quot;@+id/constraint_layout&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:background=&quot;@android:color/holo_green_light&quot;
      tools:context=&quot;.MainActivity&quot;&gt;
  
      &lt;Button
          android:id=&quot;@+id/button&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Button&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot;
          app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
      &lt;Button
          android:id=&quot;@+id/button2&quot;
          android:layout_width=&quot;0dp&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:text=&quot;Button&quot;
          app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
          app:layout_constraintEnd_toEndOf=&quot;parent&quot;
          app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  
  &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
  </code></pre>
  <p>themes:</p>
  <pre><code>&lt;style name=&quot;Theme.SystemWindowExercise&quot; parent=&quot;Theme.MaterialComponents.DayNight.NoActionBar&quot;&gt;
  </code></pre>
  <p>On the left is the app before I touched the screen with black space without system bars, but with wrong resized root layout(green color), and on the right is the app after I touched the screen with system bars and correct resized root layout.</p>
  <p><a href="https://i.stack.imgur.com/E0M5k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E0M5k.png" alt="enter image description here" /></a></p>
  <p>I want an app with a full screen without black space and with a full resized root layout and hid system bars for my splash screen before I do any interaction with the screen. How can I do that?</p>
  <p>UPDATE: I'm using minSdkVersion 22 and targetSdkVersion 29 and I tested on Samsung Galaxy A40 (Android 10, API 29).
  On Samsung, I always get a black space on the top but on ZTE Nubia (API 22) all works fine.
  The only solution until now is to change device settings like this: <a href="https://www.gottabemobile.com/how-to-enable-full-screen-apps-on-galaxy-s10/" rel="nofollow noreferrer">How to Enable Full Screen Apps on Galaxy</a> what @SlothCoding showed me in the comment.</p>
  <p>UPDATE2:
  If you do not want to change in device settings then you need this code for phones which have a camera built in the screen area or in official terms you need it to display content in cutouts area:</p>
  <pre><code> if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.P) {
          attributes.layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES
      }
  </code></pre>