Search code examples
androidsplash-screen

Splash Screen - white


For the splash screen I'm using:

setContentView(R.layout.activity_home);
new Handler().postDelayed(new Runnable() {
    @Override
    public void run() {
        startActivity(new Intent(getApplicationContext(),MainActivity.class));
    }
}, 3500);

And it's working, it shows my splash screen for 3 and a half seconds. But, when I'm starting the app, first the display is white for like a second and then it shows my splash screen. Since the code is working, could the problem be the mobile phone that I'm using instead an emulator? Or I need to add something to my code?


Solution

  • White screen is caused by AppTheme. When app is initialize it shows default white screen before setting any views.

    You can make that white screen disappear by just adding the following attribute to your AppTheme.

    Just add

    <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
        <item name="android:windowBackground"><place here any drawable or color></item>
    </style>
    

    Let me know if it is helpful to you. Thanks!!!