149

As we all know, many Android apps display a white screen very briefly before their first Activity comes into focus. This problem is observed in the following cases:

  • Android apps that extend the global Application class and perform major initializations therein. The Application object is always created before the first Activity (a fact that can be observed in the debugger), so this makes sense. This is the cause of the delay in my case.

  • Android apps that display the default preview window before the splash screen.

Setting android:windowDisablePreview = "true" obviously does not work here. Nor can I set the parent theme of the splash screen to Theme.Holo.NoActionBar as described here, because [unfortunately] my splash screen makes use of an ActionBar.

Meanwhile, apps that do not extend the Application class do not show the white screen at startup.

The thing is, ideally the initializations performed in the Application object need to occur before the first Activity is shown. So my question is, how can I perform these initializations on app startup without using an Application object? Possibly using a Thread or Service, I suppose?

This is an interesting problem to think about. I can't bypass it the usual way (by setting the NoActionBar theme), as tragically my Splash screen actually has an ActionBar due to some unrelated reasons.

Note:

I have already referred to the following questions:

References:

Community
  • 1
  • 1
Yash Sampat
  • 30,051
  • 12
  • 94
  • 120
  • 1
    You found the problem yourself, you are doing to many init in in the application context, blocking the loading of the activity, try to asynchronized this, letting a loading activity to show up until some thread ends. – AxelH May 25 '16 at 12:26
  • [This](http://stackoverflow.com/questions/35054872/how-to-pre-load-mainactivity-in-splashactivity-so-there-would-be-no-delay-when-l) might help – Atiq May 25 '16 at 12:28
  • Have you looked into lazy loading? I believe you are on the right track with services not on the main thread. – Beshoy Hanna May 25 '16 at 12:34
  • @BeshoyHanna: please explain how we would use that here ... – Yash Sampat May 25 '16 at 12:35
  • 1
    Ideally, an application would offload processing and not use the main thread for long operations. This is a well accepted practice. If the operations need to happen before the app loads, then it should an least not share a thread with the UI. – Beshoy Hanna May 25 '16 at 12:39
  • 1
    You might find that this is still an issue after you've moved all initialisationcode out of the `Application` class. This is due to newer versions of Android's way of "cold-starting" the apps. Google actually addressed the launchtimes at Google I/O this year and it will be fixed in N from what I remember. In the meantime, you should look at what Google calls a "branded launchscreen". Here's an example on how to create it: http://antonioleiva.com/branded-launch-screen/ - no more white screen in the beginning ;-) And please don't use splashscreens - it's annoying to the user. – Darwind May 25 '16 at 12:40
  • @BeshoyHanna: So I should use an `IntentService` then? – Yash Sampat May 25 '16 at 12:47
  • @Anders: interesting idea ... :) – Yash Sampat May 25 '16 at 12:48
  • @AxelH: please be more specific ... what should I use exactly? A Service? A Thread? – Yash Sampat May 25 '16 at 12:48
  • @Darwind: wow ... cool idea! Looks neat. You should post this as an answer ... :) – Yash Sampat May 25 '16 at 12:49
  • 1
    Wrt theme, the trick is not to set a NoActionBar theme, it's to adjust the initial activity's theme so that an empty themed screen looks like the fully initialized one. – zapl May 25 '16 at 12:54
  • If you use android studio 2.0 disable instant run and this issue will fixed. – Amir Jun 02 '16 at 09:56
  • Incidentally, are you aware that the `Application` instance may be retained even when all your activities have finished? When that happens, `Application#onCreate()` will *not* be called again the next time your app is launched. – Kevin Krumwiede Jun 02 '16 at 09:58
  • @KevinKrumwiede: yes, that is the case when the app is still in the background, and the app process is alive and well. If you dismiss the app, the process is killed, the `Application` instance is gone, and the white screen is back with a vengeance ... :) – Yash Sampat Jun 02 '16 at 10:14
  • @Amir: I think you may be mistaken about what I am asking. This has nothing to do with Instant Run. It is a long-running problem with Android applications. It happens irrespective of OS version and even with projects that are built with Eclipse. – Yash Sampat Jun 02 '16 at 10:17
  • What are the operations in Application#onCreate(). Is it IO? – Tin Tran Jun 08 '16 at 16:23
  • i have not extended Application class but i am still getting the white screen – Vivek Pratap Singh Sep 02 '16 at 07:26
  • What is the point of using thread, service to load something later? You don't need all that stuff when user opens your app? This doesn't make sense. Just you splash screen and that's all. Even official Google apps do it. – user25 Feb 24 '19 at 21:22

18 Answers18

125

please add this line into your app theme

<item name="android:windowDisablePreview">true</item>

for more information : https://developer.android.com/topic/performance/vitals/launch-time#themed

Geet Thakur
  • 1,966
  • 1
  • 16
  • 23
Hitesh Singh
  • 1,951
  • 1
  • 10
  • 15
  • 43
    It hang application for 2 sec and then application launch, not useful for me! – Fakhar Mar 17 '18 at 12:10
  • 4
    grate now it is not showing #ffffff color but it is now showing #000000 – Midhilaj Jul 16 '18 at 16:17
  • @Faakhir So did you find any solution? I am still looking a solution, which remove this white screen and also there's no delay at launching time. – Rupam Das Aug 10 '20 at 14:24
  • Prefect solution working for me (`compileSdkVersion 30`). Thank you! – VikaS GuttE Sep 20 '20 at 15:06
  • This works for me in Android Studio 4.1, tested on a real device – A.W. Oct 17 '20 at 05:48
  • 1
    Setting `android:windowDisablePreview` will remove the white screen on startup by not showing anything. Therefore, if during your app initialisation you are doing a lot of things (e.g. initialising external services) then your app will appear to hang (which it does not). The most appropriate solution is setting a custom `android:windowBackground`. In reality, the white screen at startup is just the default windowBackground that you are seeing. – gmetal Dec 22 '20 at 14:45
  • 1
    White window still shows even with this. – JPM May 25 '23 at 14:22
101

The problem with white background is caused because of android's cold start while the app loads to memory, and it can be avoided with this:

public class OnboardingWithCenterAnimationActivity extends AppCompatActivity {
public static final int STARTUP_DELAY = 300;
public static final int ANIM_ITEM_DURATION = 1000;
public static final int ITEM_DELAY = 300;

private boolean animationStarted = false;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    getWindow().getDecorView().setSystemUiVisibility(
            View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_onboarding_center);
}

@Override
public void onWindowFocusChanged(boolean hasFocus) {

    if (!hasFocus || animationStarted) {
        return;
    }

    animate();

    super.onWindowFocusChanged(hasFocus);
}

private void animate() {
    ImageView logoImageView = (ImageView) findViewById(R.id.img_logo);
    ViewGroup container = (ViewGroup) findViewById(R.id.container);

    ViewCompat.animate(logoImageView)
        .translationY(-250)
        .setStartDelay(STARTUP_DELAY)
        .setDuration(ANIM_ITEM_DURATION).setInterpolator(
            new DecelerateInterpolator(1.2f)).start();

    for (int i = 0; i < container.getChildCount(); i++) {
        View v = container.getChildAt(i);
        ViewPropertyAnimatorCompat viewAnimator;

        if (!(v instanceof Button)) {
            viewAnimator = ViewCompat.animate(v)
                    .translationY(50).alpha(1)
                    .setStartDelay((ITEM_DELAY * i) + 500)
                    .setDuration(1000);
        } else {
            viewAnimator = ViewCompat.animate(v)
                    .scaleY(1).scaleX(1)
                    .setStartDelay((ITEM_DELAY * i) + 500)
                    .setDuration(500);
        }

        viewAnimator.setInterpolator(new DecelerateInterpolator()).start();
    }
}
}

layout

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorPrimary"
android:orientation="vertical"
>

<LinearLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:gravity="center"
    android:orientation="vertical"
    android:paddingTop="144dp"
    tools:ignore="HardcodedText"
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="16dp"
        android:alpha="0"
        android:text="Hello world"         android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse"
        android:textColor="@android:color/white"
        android:textSize="22sp"
        tools:alpha="1"
        />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="8dp"
        android:alpha="0"
        android:gravity="center"
        android:text="This a nice text"
      android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse"
        android:textSize="20sp"
        tools:alpha="1"
        />

    <Button
        android:id="@+id/btn_choice1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="48dp"
        android:scaleX="0"
        android:scaleY="0"
        android:text="A nice choice"
        android:theme="@style/Button"
        />

    <Button
        android:id="@+id/btn_choice2"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:scaleX="0"
        android:scaleY="0"
        android:text="Far better!"
        android:theme="@style/Button"
        />

</LinearLayout>

<ImageView
    android:id="@+id/img_logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:src="@drawable/img_face"
    tools:visibility="gone"
    />
</FrameLayout>

img face

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
        android:opacity="opaque">

<item android:drawable="?colorPrimary"/>
<item>
    <bitmap
        android:gravity="center"
        android:src="@drawable/img_face"/>
</item>

Add this theme to your splashscreen in the manifest

<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="android:windowBackground">@null</item>
</style>

<style name="AppTheme.CenterAnimation">
    <item name="android:windowBackground">@drawable/ll_face_logo</item>
</style>

which will produce efect like this

a busy cat

for more details and more solutions you can check this BlogPost

Ivan Milisavljevic
  • 2,048
  • 2
  • 13
  • 21
  • 5
    it didnt help still white screen and animation at end – Mehvish Ali May 11 '17 at 11:17
  • This is straight forward implementation. There could be some other parts of your code that causing the issue. Please open another question and il be there to help you:) – Ivan Milisavljevic May 11 '17 at 20:04
  • 1
    I solved this issue by animating between themes and changing the theme with no drawable but just the back color same and then on onWindowFocusChanged() mad the content visible and the animated it other wise my whited down between the transition as well. animation of themes helped alot – Mehvish Ali May 13 '17 at 09:49
  • nice value `animationStarted` that you never change – i30mb1 Sep 16 '20 at 11:15
  • nice solution .I saw a app .but it was a loading screen . i thought .how they achieve it .i look it into youtube .they also white screen with youtube icon.now i found it this it – lava Oct 27 '20 at 14:22
40

Recommended way of solving this problem is missing in the answers. So I am adding my answer here. The white-screen-at-startup problem occurs because of the initial blank screen that the system process draws when launching the app. A common way to solve this is by turning off this initial screen by adding this to your styles.xml file.

<item name="android:windowDisablePreview">true</item>

But according to android documentation this can result in longer startup time. Recommended way of avoiding this initial white screen according to google is to use activity's windowBackground theme attribute and provide a simple custom drawable for the starting activity.

Like this:

Drawable Layout file, my_drawable.xml

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
  <!-- The background color, preferably the same as your normal theme -->
  <item android:drawable="@android:color/white"/>
  <!-- Your product logo - 144dp color version of your app icon -->
  <item>
    <bitmap
      android:src="@drawable/product_logo_144dp"
      android:gravity="center"/>
  </item>
</layer-list>

Create a new style in your styles.xml

<!-- Base application theme. -->
<style name="AppTheme">
    <!-- Customize your theme here. -->               
</style>

<!-- Starting activity theme -->
<style name="AppTheme.Launcher">
    <item name="android:windowBackground">@drawable/my_drawable</item>
</style>

Add this theme to your starting activity in the Manifest file

<activity ...
android:theme="@style/AppTheme.Launcher" />

And when you want to transition back to your normal theme call setTheme(R.style.Apptheme) before calling super.onCreate() and setContentView()

public class MainActivity extends AppCompatActivity {
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    // Make sure this is before calling super.onCreate
    setTheme(R.style.Theme_MyApp);
    super.onCreate(savedInstanceState);
    // ...
  }
}

This is the recommended way to solve the problem and this is from google Material Design patterns.

Sam
  • 2,935
  • 1
  • 19
  • 26
  • 1
    looks promising, but Android says at runtime "Binary XML file line #7: requires a valid 'src' attribute". Maybe the drawables are not loaded so early in the app launch process ? – Jerem Lachkar Nov 03 '20 at 16:50
  • Hey @JeremLachkar - I got the same error, but solved it. cannot load xml icons / vectors (at that time?) but using PNGs worked for me! – KYL3R Jan 02 '21 at 13:51
  • Just remove the bitmap and use this instead : ` ` – Rajnish Sharma Jan 27 '21 at 16:33
  • This delayed any screen from opening for the app for around 4 seconds for me. Felt like the app icon was never touched. Run on cheap Samsung Galaxy A02s – landnbloc Apr 14 '22 at 18:28
  • This worked for me. I created a drawable with a blue background. In my theme in the /res/valyes/themes.xml i added the `@drawable/my_drawable line.` – Mc_Topaz Feb 01 '23 at 16:14
38

Please copy and paste these two lines in your manifest app theme i.e res/styles/AppTheme. then it will work like charm..

<item name="android:windowDisablePreview">true</item>
<item name="android:windowIsTranslucent">true</item>
prasad reddy
  • 399
  • 3
  • 7
21

First of all, to remove the white screen read this - https://www.bignerdranch.com/blog/splash-screens-the-right-way/

But more importantly, optimize your initial load and defer any heavy work to when you have time to run it. Post your application class here if you want us to take a look at it.

Shmuel
  • 3,916
  • 2
  • 27
  • 45
21

Have you tried setting theandroid:windowBackground attribute in the theme of your launcher activity, to either a color or a drawable?

For example this:

<item name="android:windowBackground">@android:color/black</item>

when added to the Launcher activity theme will show a black color (rather than the white color) on startup. This is an easy trick to hide long initialisation, while showing your users something, and it works fine even if you subclass the Application object.

Avoid using other constructs (even Threads) for doing long initialisation tasks, because you may end up not being able to control the lifecycle of such constructs. The Application object is the correct place for doing exactly this type of actions.

gmetal
  • 2,908
  • 2
  • 11
  • 16
17

I added the following two lines in my theme under styles.xml

    <item name="android:windowDisablePreview">true</item>
    <item name="android:windowBackground">@null</item>

Worked like a charm

Akanshi Srivastava
  • 1,160
  • 13
  • 24
11

I had same issue, you have to update your style.

style.xml

<!-- Base application theme. -->
 <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">

        <!-- Customize your theme here. -->
        <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:windowDisablePreview">true</item>
        <item name="android:windowBackground">@null</item>
        <item name="android:windowIsTranslucent">true</item>

 </style>

Your manifest file should looks like below.

<application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme">
     // Other stuff
</application>

Outout:

enter image description here

Hope this would help you.

Hiren Patel
  • 52,124
  • 21
  • 173
  • 151
  • 2
    That works great for me on a NativeActivity OpenGL application. I'm not sure why this is not higher up in the answers as it is the most complete and expedient answer. No Java involved just a couple of XML file changes. – Slion Aug 02 '18 at 19:59
7

Within the lifecycle callback methods, you can declare how your activity behaves when the user leaves and re-enters the activity. Remember that the way Android is designed, there is a lifecycle for each and every app. If you put too much load to the onCreate() method (which is the method used to load the layout files and initalise any controls you have in it), then the white screen will become more visible, as the layout file will take longer to load.

I suggest using several different methods when starting an activity. Such are the onStart() (being called as the first thing once the app is loaded), onActivityCreated() (being called after the layout is displayed and useful if you are making any data processing upon starting the activity).

To make it easier for you, below is the official activity lifecycle diagram (from http://web.archive.org/web/20140218132043/http://developer.android.com/training/basics/activity-lifecycle/starting.html):

enter image description here

General Grievance
  • 4,555
  • 31
  • 31
  • 45
Michele La Ferla
  • 6,775
  • 11
  • 53
  • 79
  • Thank you for your answer, it was very interesting. However, I believe you misunderstood my question. The problem is not caused by the initializations in the first `Activity`, but those in the global `Application` object. And I don't believe I can apply such a separation of concerns there, because unlike an `Activity` it only has an `onCreate()` method. – Yash Sampat Jun 07 '16 at 05:33
  • Why are you extending the application class and not the activity one? – Michele La Ferla Jun 08 '16 at 10:46
  • Okay, so you mean I should abandon the `Application` object altogether and move all the initialization code to the first `Activity` ... – Yash Sampat Jun 08 '16 at 11:01
  • That's how I've always developed my apps, however if you don't wish to make all those changes, other answers might help you get around your issue using the application class. For your future reference, I recommend using the one activity class immediately, and then many fragments. Hope this helps :) – Michele La Ferla Jun 08 '16 at 11:06
3

Please try this once.

  1. Create a drawable file splash_background.xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@color/{your color}" />

    <item>
        <bitmap
            android:layout_width="@dimen/size_250"
            android:layout_height="@dimen/size_100"
            android:gravity="center"
            android:scaleType="fitXY"
            android:src="{your image}"
            android:tint="@color/colorPrimary" />
    </item>

</layer-list>
  1. Put this in styles.xml

      <style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
          <item name="android:windowBackground">@drawable/splash_background</item>
      </style>
    
  2. In your AndroidMainfest.xml set the above theme to Launch activity.

        <activity
             android:name=".SplashScreenActivity"
             android:screenOrientation="portrait"
             android:theme="@style/SplashTheme"
             android:windowSoftInputMode="stateVisible|adjustResize">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
    
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
    
Surendar D
  • 5,554
  • 4
  • 36
  • 38
3

According to Google's recommendation Here, you should not prevent this white screen from launching. You can use this theme attribute to turn off the initial blank screen that the system process draws when launching the app.

<item name="android:windowDisablePreview">true</item>

However, This approach is not recommended because it can result in a longer startup time than apps that don’t suppress the preview window. Also, it forces the user to wait with no feedback while the activity launches, making them wonder if the app is functioning properly.

They recommend to use the activity's windowBackground theme attribute to provide a simple custom drawable for the starting activity instead of disabling the preview window.

Therefore, here is the recommended solution:

First, create a new drawable file for example startup_screen.xml

 <layer-list xmlns:android="http://schemas.android.com/apk/res/android" android:opacity="opaque">
    <!-- The background color, preferably the same as normal theme -->
    <item android:drawable="@android:color/white"/>
    <!-- Product logo - 144dp color version of App icon -->
    <item>
        <bitmap
            android:src="@drawable/logo"
            android:gravity="center"/>
    </item>
 </layer-list>

Second, reference it from your style file. If you use Night mode. Add it in both themes.xml files.

<!-- Start Up Screen -->
<style name="AppThemeLauncher" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
     <item name="android:statusBarColor" tools:targetApi="l">@color/lightGray</item>
     <item name="android:windowBackground">@drawable/startup_screen</item>
</style>

If you notice, I added statusBarColor attribute to change the color of status Bar according to my custom design.

Then, Add AppThemeLauncher Theme in your current activity.

<activity
    android:name=".MainActivity"
    android:theme="@style/AppThemeLauncher"/>

If you want to transition back to your normal theme, call setTheme(R.style.AppTheme) before calling super.onCreate() and setContentView():

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        // Make sure this is before calling super.onCreate
        setTheme(R.style.AppTheme)
        super.onCreate(savedInstanceState)
        // ...
    }
}
Marwa Eltayeb
  • 1,921
  • 1
  • 17
  • 29
2

Did you try to put initialization to onActivityCreated?

Inside Application class :

 registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
            @Override
            public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
                if(activity.getClass().equals(FirstActivity.class) {
                    // try without runOnUiThread if it will not help
                    activity.runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            new InitializatioTask().execute();
                        }
                    });
                }
            }

            @Override
            public void onActivityStarted(Activity activity) {

            }

            @Override
            public void onActivityResumed(Activity activity) {

            }

            @Override
            public void onActivityPaused(Activity activity) {

            }

            @Override
            public void onActivityStopped(Activity activity) {

            }

            @Override
            public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

            }

            @Override
            public void onActivityDestroyed(Activity activity) {

            }
        });
Sergey Shustikov
  • 15,377
  • 12
  • 67
  • 119
2

As you are already aware why this white screen is there, as due to background processes or application initialization or large files, so just check below idea for overcome from this.

To prevent this white screen on beginning of the app, one way is splash screen, this is just a way not final and you must have to use.

When you will show splash screen from your splash.xml file, then also this issue will be remain same,

So you have to create ont style in style.xml file for splash screen and there you have to set window background as your splash image and then apply that theme to your splash activity from manifest file. So now when you will run app, first it will set theme and by this way user will be able to see directly splash image instead of white screen.

Vickyexpert
  • 3,147
  • 5
  • 21
  • 34
2

Both properties works

    <style name="AppBaseThemeDark" parent="@style/Theme.AppCompat">
            <!--your other properties -->
            <!--<item name="android:windowDisablePreview">true</item>-->
            <item name="android:windowBackground">@null</item>
            <!--your other properties -->
    </style>
Sohail Zahid
  • 8,099
  • 2
  • 25
  • 41
0

Just write the item in values/styles.xml:

<item name="android:windowBackground">@android:color/black</item>

For example, in the AppTheme:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>

    <item name="android:windowBackground">@android:color/black</item>

    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>
Pang
  • 9,564
  • 146
  • 81
  • 122
0
Style :- 
<style name="SplashViewTheme" parent="Theme.AppCompat.NoActionBar">
    <item name="android:windowBackground">@drawable/splash</item>
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

In Manifest :- 
<activity android:name=".SplashActivity"
        android:theme="@style/SplashViewTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Krishna
  • 1,556
  • 13
  • 21
0

You should have colors.xml on values-night (create alongside values folder if it doesn't already exist) folder for dark theme colors. eg.

<resources>
    <color name="status_bar">#0e0e0e</color>
</resources>

(colors.xml on regular values folder will be used for light theme)

And on styles.xml which supplies your app theme you will have entry for background and statusbar which takes necessary values. eg.

<style name="Theme.<AppName>" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/red700</item>
        <item name="colorPrimaryDark">@color/red900</item>
        <item name="colorAccent">@color/red700</item>
        <item name="android:statusBarColor">@color/status_bar</item>
        <item name="android:background">@color/status_bar</item>
    </style>

This style is referenced on AndroidManifest.xml file

android:theme="@style/Theme.<AppName>">
asok Buzz
  • 1,876
  • 3
  • 24
  • 50
-1

Delete

<style name="AppTheme.Launcher">
    <item name="android:windowBackground">@drawable/splashscreen</item>
</style>

from style.xml file

ranojan
  • 819
  • 8
  • 11