These answers here seem a bit misleading. The question asks how to add this to a splash screen with react native. The solutions say how to add gifs to the project but not how to add them to a splashscreen.
A splash screen is meant to be loaded before the JS bundle loads IE the render
methods from react native will not be accessible before the JS bundle loads.
Solution: Android
Can actually have a gif directly in the splashscreen
Resources: Can I Add GIF format Image as a Splash Screen
Look at this repo as an example of integrating a gif into your splashscreen.
https://github.com/koral--/android-gif-drawable
I got it working tonight (4/12/2020) with react native 0.62
Steps:.
- Follow the react-native-splash-screen tutorial to create
/layout/launch_screen/xml
- Add in the android-gif-drawable api
- Bring a gif into the drawable folder and then link it like this:
layout/launch_screen.xml
the @drawable/tutorial
is my gif titled tutorial.gif
<?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:background="@color/splashscreen_bg"
android:layout_height="match_parent">
<pl.droidsonroids.gif.GifImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/tutorial"
/>
</RelativeLayout>
styles.xml
I was able to hide the white screen flash by using <item name="android:windowDisablePreview">true</item>
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="android:textColor">#000000</item>
<!-- Add the following line to set the default status bar color for all the app. -->
<item name="android:statusBarColor">@color/app_bg</item>
<!-- Add the following line to set the default status bar text color for all the app
to be a light color (false) or a dark color (true) -->
<item name="android:windowLightStatusBar">false</item>
<!-- Add the following line to set the default background color for all the app. -->
<item name="android:windowBackground">@color/app_bg</item>
<!-- Prevents white screen from appearing when opening the app -->
<item name="android:windowDisablePreview">true</item>
</style>
</resources>
Solution: iOS
- Create a static splash screen with a static logo asset
- After launch render an identical screen with the animated version of the logo
Hope this helps everyone!