question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android: Flash before SplashScreen.hide();

See original GitHub issue

Noticing a flash upon load on Android no matter how I modify my configuration. The flash goes to white if background_splash.xml is removed, the flash goes to white instead.

MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    SplashScreen.show(this, true);
    super.onCreate(savedInstanceState);
}

launch_screen.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
    <ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:src="@drawable/screen" android:scaleType="centerCrop" />
</RelativeLayout>

styles.xml

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.ReactNative.AppCompat.Light.NoActionBar.FullScreen">
        <!-- Customize your theme here. -->
        <item name="android:windowBackground">@drawable/background_splash</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowDisablePreview">true</item>
    </style>
</resources>

background_splash.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <bitmap android:gravity="fill" android:src="@drawable/screen"/>
    </item>
</selector>

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:9

github_iconTop GitHub Comments

37reactions
chr4ss1commented, Mar 20, 2019

I fixed the “white flashing issue”, however not 100% sure which part fixed it.

Here is the tutorial I followed: https://medium.com/handlebar-labs/how-to-add-a-splash-screen-to-a-react-native-app-ios-and-android-30a3cec835ae

After that tutorial, I had white flashing.

Then I applied the next changes in the styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowDisablePreview">true</item>
        <item name="android:windowBackground">@drawable/background_splash</item>
    </style>

    <style name="SplashTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowBackground">@drawable/background_splash</item>
    </style>
</resources>

and it started to work (no flashing white)

8reactions
josecarlosnscommented, Jul 22, 2019

@ChrisEelmaa I’m having this issue too and your fix worked for me.

I tested a little and what seems to happen is that the flash is actually the empty MainActivity showing for an instant, before the interface renders. So your fix works because you set the background color/image of the base application AppTheme to be the same of the Splash Screen, so the ‘flash’ is still happening, but its of the same color so you don’t notice it.

You can even remove the <item name="android:windowDisablePreview">true</item>, it doesn’t matter for this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - blank screen comes before splash - Stack Overflow
Before splash screen a blank layout appears which I don't want. Otherwise it runs fine. Just want to remove the blank layout which...
Read more >
Splash screens - Android Developers
Exit animation: This consists of the animation run that hides the splash screen. If you want to customize it, you'll have access to...
Read more >
Splash Screen Tutorial for Android - Kodeco
Learn how to implement splash screen in new and existing Android apps, using the SplashScreen API introduced in Android 12.
Read more >
Splash Screen - Apache Cordova
SplashScreenDelay. Amount of time in milliseconds to wait before automatically hide splash screen. Supported Platforms: Android; iOS. Data Type: ...
Read more >
flutter_native_splash | Flutter Package - Pub.dev
Customize Flutter's default white native splash screen with background color ... app has initialized, make a call to remove() to remove the splash...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found