react-native-bootsplash
Show a bootsplash during app startup. Hide it when you are ready.
Support
version | react-native version |
---|---|
0.1.1+ | 0.60.0+ |
Installation
Setup
iOS
Edit the ios/YourProjectName/AppDelegate.m
file:
Android
- Create a
bootsplash.xml
file inandroid/app/src/main/res/drawable
(create the folder if necessary). You can customize this as you want.
- Edit the
android/app/src/main/java/com/yourprojectname/MainActivity.java
file:
As Android will not create our main activity before launching the app, we need to display a different activity at start, then switch to our main one.
- Edit the
android/app/src/main/res/values/styles.xml
file:
- Edit the
android/app/src/main/AndroidManifest.xml
file:
Usage
? A more complex example is available in the /example
folder.
? Manual linking
Because this package targets React Native 0.60+, you will probably don't need to link it. Otherwise if you follow all the previous steps and it still doesn't work, try to link this library manually:
iOS
Add this line to your ios/Podfile
file, then run pod install
.
Android
- Add the following lines to
android/settings.gradle
:
- Add the implementation line to the dependencies in
android/app/build.gradle
:
- Add the import and link the package in
MainApplication.java
:
?️♂️ Comparaison with react-native-splash-screen
-
If
react-native-splash-screen
encourages you to display an image over your application,react-native-bootsplash
way-to-go is to design your launch screen using platforms tools (Xcode layout editor and Android drawable resource). -
Instead of displaying the launch screen over the main
UIView
/Activity
, it will be displayed inside it. This prevents "jump" during transition (like in the example: horizontal & vertical centering using iOS auto layout or android gravity params will match perfectly the mounted component which uses{ alignItems: "center"; justifyContent: "center" }
to center its logo). -
It should not prevents you from seeing red screen errors.
-
Hiding the launch screen is configurable: fade it out with a custom duration or hide it without any animation at all (no fade needed if you want to animate it out!).