title: Centered image on windowBackground is different than on an inflated layout
body: <p>I tried to implement a "slash screen" and I faced an issue where the image on splashscreen is not really centered, some times it jumps up and sometimes down and sometimes it's well placed.</p>
  
  <p>First of all, the issue:</p>
  
  <p><a href="https://i.stack.imgur.com/veTRd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/veTRd.png" alt="enter image description here"></a></p>
  
  <p>So here you can see my logo, the first one to show up is the one that is in Red, it's declared like this :</p>
  
  <p><strong>background_splash.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;!-- Background color --&gt;
      &lt;item android:drawable="@color/colorPrimaryDark" /&gt;
  
      &lt;!-- Logo at the center of the screen --&gt;
      &lt;item
          android:width="300dp"
          android:height="300dp"
          android:gravity="center"&gt;
          &lt;bitmap android:src="@drawable/ic_launcher_sablier" /&gt;
      &lt;/item&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>And added like this:</p>
  
  <p><strong>styles.xml</strong></p>
  
  <pre><code>&lt;style name="SplashTheme" parent="AppTheme"&gt;
      &lt;item name="android:windowBackground"&gt;@drawable/background_splash&lt;/item&gt;
  &lt;/style&gt;
  </code></pre>
  
  <p>Then the view with the Blue one is shown, it's declared like this :</p>
  
  <p><strong>activity_splash.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/linearLayoutSplash"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:animateLayoutChanges="true"
      android:background="@color/colorPrimaryDark"
      android:gravity="center"
      android:orientation="vertical"&gt;
  
      &lt;androidx.appcompat.widget.AppCompatImageView
          android:id="@+id/imageViewSplash"
          android:layout_width="300dp"
          android:layout_height="300dp"
          app:srcCompat="@drawable/ic_launcher_sablier" /&gt;
  
      &lt;ProgressBar
          android:id="@+id/progressSplash"
          android:layout_width="40dp"
          android:layout_height="40dp"
          android:layout_marginTop="12dp"
          android:indeterminateTint="@color/grey_light"
          android:visibility="gone" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>It's just like the windowBackground is taking into consideration something else (StatusBar height, etc.) and it's not really centered on the screen.</p>
  
  <p>I've tried this:</p>
  
  <pre><code>&lt;item name="android:windowDrawsSystemBarBackgrounds"&gt;false&lt;/item&gt;
  </code></pre>
  
  <p>and/or</p>
  
  <pre><code>&lt;item name="android:windowNoTitle"&gt;true&lt;/item&gt;
  </code></pre>
  
  <p>and/or</p>
  
  <pre><code>&lt;item name="android:windowContentOverlay"&gt;@drawable/background_splash&lt;/item&gt;
  </code></pre>
  
  <p>And nothing is working.</p>
  
  <p>At a moment I said to myself it's ok if it's not working under api 26 so I used that :</p>
  
  <p><strong>v26/style.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
      &lt;style name="SplashTheme" parent="AppTheme"&gt;
          &lt;item name="android:windowSplashscreenContent"&gt;@drawable/background_splash&lt;/item&gt;
      &lt;/style&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>And same issue.</p>
  
  <p>So finally I was thinking to move the inflated view up/or down instead of trying to place correctly the window background, it's not a big problem if it's not exactly centered in the screen so I tried to remove Status bar height, and it was working on some devices but not on others, and etc...</p>
  
  <p>It's working on Nexus 5 with the specific v26/style.xml I shared before, so that is exactly what I want : </p>
  
  <p><a href="https://i.stack.imgur.com/rjADT.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/rjADT.gif" alt="enter image description here"></a></p>
  
  <p>And what happen on my Xiaomi MI 8 for example (it also happen on a Pixel 2XL, on some Huawei,...):</p>
  
  <p><a href="https://i.stack.imgur.com/I517a.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/I517a.gif" alt="enter image description here"></a></p>
  
  <p>So if someone have a solution <strong>to center correctly the windowBackground OR to move the inflated view accordingly</strong>, I will be happy with both !</p>
  
  <p>Thx to you to help me !</p>
  
  <p><strong>EDIT 13/08:</strong></p>
  
  <p>Here the AppTheme you asked for :</p>
  
  <pre><code>&lt;!-- Base application theme. --&gt;
      &lt;style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"&gt;
          &lt;!-- Customize your theme here. --&gt;
          &lt;item name="colorPrimary"&gt;@color/colorPrimary&lt;/item&gt;
          &lt;item name="colorPrimaryDark"&gt;@color/colorPrimaryDark&lt;/item&gt;
          &lt;item name="colorAccent"&gt;@color/colorAccent&lt;/item&gt;
      &lt;/style&gt;
  </code></pre>