Android: Flash before SplashScreen.hide();
See original GitHub issueNoticing 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:
- Created 5 years ago
- Reactions:6
- Comments:9
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:
and it started to work (no flashing white)
@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 applicationAppTheme
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.