Name Date Size #Lines LOC

..26-Sep-2023-

android/H26-Sep-2023-958684

assets/H26-Sep-2023-

build/H26-Sep-2023-6715

ios/H26-Sep-2023-723551

plugin/H26-Sep-2023-4534

src/H26-Sep-2023-4011

.babelrcH A D26-Sep-202339 43

.eslintrc.jsH A D26-Sep-2023103 31

.npmignoreH A D26-Sep-202328 32

CHANGELOG.mdH A D26-Sep-202313.9 KiB338177

README.mdH A D26-Sep-202333.9 KiB802581

app.plugin.jsH A D26-Sep-202361 21

babel.config.jsH A D26-Sep-2023104 31

expo-module.config.jsonH A D26-Sep-2023154 87

package.jsonH A D26-Sep-20231.1 KiB4645

tsconfig.jsonH A D26-Sep-2023217 109

README.md

1<p>
2  <a href="https://docs.expo.dev/versions/latest/sdk/splash-screen/">
3    <img
4      src="../../.github/resources/expo-splash-screen.svg"
5      alt="expo-splash-screen"
6      height="64" />
7  </a>
8</p>
9
10`expo-splash-screen` allows you to customize your app's splash screen, which is the initial screen users see when the app is launched, before it has loaded. Splash screens (sometimes called launch screens) provide a user's first experience with your application.
11
12- [�� CHANGELOG](./CHANGELOG.md)
13- [�� Features](#-features)
14- [�� API](#-api)
15- [�� Examples](#-examples)
16- [�� Installation in managed Expo projects](#-installation-in-managed-expo-projects)
17- [�� Installation in bare React Native projects](#-installation-in-bare-react-native-projects)
18  - [�� Configure iOS](#-configure-ios)
19  - [�� Configure Android](#-configure-android)
20- [�� Contributing](#-contributing)
21- [❓ Known issues](#-known-issues)
22- [⬆️ Migrate from old versions](#%EF%B8%8F-migrate-from-old-versions)
23- [�� Hall of fame](#-hall-of-fame)
24
25## �� Features
26
27### Built-in splash screen image resize modes
28
29`expo-splash-screen` contains a built-in feature for taking care of properly displaying your splash screen image. You can use the following resize modes to obtain behavior as if you were using the React Native `<Image>` component's `resizeMode` style.
30
31#### `CONTAIN` resize mode
32
33Scale the image uniformly (maintaining the image's aspect ratio) so that both dimensions the width and height of the image will be equal to or less than the corresponding dimension of the device's screen.
34
35<table>
36  <thead><tr><td>Android</td><td>iOS</td></tr></thead>
37  <tbody><tr>
38<td>
39
40https://user-images.githubusercontent.com/379606/120575867-aeeb3580-c3d6-11eb-825d-19a847fe30f5.mp4
41
42</td>
43<td>
44
45https://user-images.githubusercontent.com/379606/120575885-b6124380-c3d6-11eb-8485-75a11832962c.mp4
46
47</td>
48    </tr>
49  </tbody>
50</table>
51
52#### `COVER` resize mode
53
54Scale the image uniformly (maintaining the image's aspect ratio) so that both the width and height of the image will be equal to or larger than the corresponding dimension of the device's screen.
55
56<table>
57  <thead><tr><td>Android</td><td>iOS</td></tr></thead>
58  <tbody><tr>
59<td>
60
61https://user-images.githubusercontent.com/379606/120575871-b1e62600-c3d6-11eb-9435-5dee19791294.mp4
62
63</td>
64<td>
65
66https://user-images.githubusercontent.com/379606/120575890-b7437080-c3d6-11eb-9c0a-3c563d1ee02a.mp4
67
68</td>
69    </tr>
70  </tbody>
71</table>
72
73#### `NATIVE` resize mode
74
75> **Android only.**
76
77By using this resize mode your app will will leverage Android's ability to present a static bitmap while the application is starting up.
78Android (unlike iOS) does not support stretching of the provided image during launch, so the application will present the given image centered on the screen at its original dimensions.
79
80<table>
81  <thead><tr><td>Android</td></tr></thead>
82  <tbody><tr>
83<td>
84
85https://user-images.githubusercontent.com/379606/120575878-b3afe980-c3d6-11eb-80c1-72441c22e8be.mp4
86
87</td>
88    </tr>
89  </tbody>
90</table>
91
92> Animation above presents one of our [known issues](#native-mode-pushes-splash-image-up-a-little-bit)
93
94Selecting this resize mode requires some more work to be done in native configuration.
95Please take a look at the [`res/drawable/splashscreen.xml`](#resdrawablesplashscreenxml) and [`res/drawable/splashscreen_background.png`](#resdrawablesplashscreen_backgroundpng) sections.
96
97### Per-appearance (a.k.a. dark-mode) splash screen
98
99`expo-splash-screen` supports per-appearance splash screens that respond to system appearance changes on iOS 13+ and dark-mode changes on Android 10+.
100
101### StatusBar customization
102
103`expo-splash-screen` allows customization of the StatusBar according to the [ReactNative StatusBar API](https://reactnative.dev/docs/statusbar).
104
105## �� API
106
107```tsx
108import * as SplashScreen from 'expo-splash-screen';
109```
110
111The native splash screen that is controlled via this module autohides once the ReactNative-controlled view hierarchy is mounted. This means that when your app first `render`s view component, the native splash screen will hide. This default behavior can be prevented by calling [`SplashScreen.preventAutoHideAsync()`](#splashscreenpreventautohideasync) and later on [`SplashScreen.hideAsync()`](#splashscreenhideasync).
112
113### `SplashScreen.preventAutoHideAsync()`
114
115This method makes the native splash screen stay visible until [`SplashScreen.hideAsync()`](#splashscreenhideasync) is called. This must be called before any ReactNative-controlled view hierarchy is rendered (either in the global scope of your main component, or when the component renders `null` at the beginning - see [Examples section](#-examples)).
116
117Preventing default autohiding might come in handy if your application needs to prepare/download some resources and/or make some API calls before first rendering some actual view hierarchy.
118
119#### Returns
120
121A `Promise` that resolves to `true` when preventing autohiding succeeded and to `false` if the native splash screen is already prevented from autohiding (for instance, if you've already called this method).
122`Promise` rejection most likely means that native splash screen cannot be prevented from autohiding (it's already hidden when this method was executed).
123
124### `SplashScreen.hideAsync()`
125
126Hides the native splash screen. Only works if the native splash screen has been previously prevented from autohiding by calling [`SplashScreen.preventAutoHideAsync()`](#splashscreenpreventautohideasync) method.
127
128#### Returns
129
130A `Promise` that resolves to `true` once the splash screen becomes hidden and to `false` if the splash screen is already hidden.
131
132## �� Examples
133
134### `SplashScreen.preventAutoHideAsync()` in global scope
135
136`App.tsx`
137
138```tsx
139import React from 'react';
140import { StyleSheet, Text, View } from 'react-native';
141import * as SplashScreen from 'expo-splash-screen';
142
143// Prevent native splash screen from autohiding before App component declaration
144SplashScreen.preventAutoHideAsync()
145  .then((result) => console.log(`SplashScreen.preventAutoHideAsync() succeeded: ${result}`))
146  .catch(console.warn); // it's good to explicitly catch and inspect any error
147
148export default class App extends React.Component {
149  componentDidMount() {
150    // Hides native splash screen after 2s
151    setTimeout(async () => {
152      await SplashScreen.hideAsync();
153    }, 2000);
154  }
155
156  render() {
157    return (
158      <View style={styles.container}>
159        <Text style={styles.text}>SplashScreen Demo! ��</Text>
160      </View>
161    );
162  }
163}
164
165const styles = StyleSheet.create({
166  container: {
167    flex: 1,
168    alignItems: 'center',
169    justifyContent: 'center',
170    backgroundColor: '#aabbcc',
171  },
172  text: {
173    color: 'white',
174    fontWeight: 'bold',
175  },
176});
177```
178
179### `SplashScreen.preventAutoHideAsync()` in component that initially renders `null`
180
181`App.tsx`
182
183```tsx
184import React from 'react';
185import { StyleSheet, Text, View } from 'react-native';
186import * as SplashScreen from 'expo-splash-screen';
187
188export default class App extends React.Component {
189  state = {
190    appIsReady: false,
191  };
192
193  async componentDidMount() {
194    // Prevent native splash screen from autohiding
195    try {
196      await SplashScreen.preventAutoHideAsync();
197    } catch (e) {
198      console.warn(e);
199    }
200    this.prepareResources();
201  }
202
203  /**
204   * Method that serves to load resources and make API calls
205   */
206  prepareResources = async () => {
207    await performAPICalls(...);
208    await downloadAssets(...);
209
210    this.setState({ appIsReady: true }, async () => {
211      await SplashScreen.hideAsync();
212    });
213  }
214
215  render() {
216    if (!this.state.appIsReady) {
217      return null;
218    }
219
220    return (
221      <View style={styles.container}>
222        <Text style={styles.text}>SplashScreen Demo! ��</Text>
223      </View>
224    )
225  }
226}
227
228const styles = StyleSheet.create({
229  container: {
230    flex: 1,
231    alignItems: 'center',
232    justifyContent: 'center',
233    backgroundColor: '#aabbcc',
234  },
235  text: {
236    color: 'white',
237    fontWeight: 'bold',
238  },
239});
240```
241
242## �� Installation in managed Expo projects
243
244Refer to [the SplashScreen section of the Expo documentation](https://docs.expo.dev/versions/latest/sdk/splash-screen/).
245
246## �� Installation in bare React Native projects
247
248For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
249
250## Add the package to your dependencies
251
252```
253npx expo install expo-splash-screen
254```
255
256## �� Configure iOS
257
258Run `npx pod-install` after installing the package.
259
260### Manual Configuration
261
262To achieve native splash screen (in iOS ecosystem it's called `LaunchScreen`) behavior, you have to provide either a `SplashScreen.storyboard` file or a `SplashScreen.xib` file, and configure your Xcode project accordingly.
263
264The guide below shows how to configure your Xcode project to use a single image file as a splash screen using a `.storyboard` file (configuration for `.xib` filetype is analogous).
265
2661. [Add an image to `Images.xcassets`](#-add-an-image-to-imagesxcassets)
2672. [Create `SplashScreen.storyboard`](#-create-splashscreenstoryboard)
2683. [Select `Content Mode` for the `ImageView` in `SplashScreen.storyboard`](#-select-content-mode-for-the-imageview-in-splashscreenstoryboard)
2694. [Mark `SplashScreen.storyboard` as the LaunchScreen](#-mark-splashscreenstoryboard-as-the-launchscreen)
2705. [(<em>optional</em>) Enable dark mode](#-optional-enable-dark-mode)
2716. [(<em>optional</em>) Customize StatusBar](#-customize-statusbar)
272
273#### �� Add an image to `Images.xcassets`
274
275First you need to add the image file that would serve as a splash screen to your native project's resources.
276
2771. In your Xcode project open the `.xcassets` (often named `Images.xcassets` or `Assets.xcassets`) file.
2782. In the content panel add `New image set` and name it `SplashScreen`.
2793. Provide the splash screen image you've prepared (you have to provide it in three different scales).
280
281<details>
282 <summary>Show image with details</summary>
283<img src="./assets/configuration-ios-addImagesXcassets.png" height="350" />
284</details>
285
286#### �� Create `SplashScreen.storyboard`
287
288This is the actual splash screen definition and will be used by the system to render your splash screen.
289
2901. Create a `SplashScreen.storyboard` file.
2912. Add a `View Controller` to the newly created `.storyboard` file:
292   - open `Library` (`+` button on the top-right),
293   - find `View Controller` element,
294   - drag-and-drop it to the `.storyboard` file.
295
296<details>
297 <summary>Show image with details</summary>
298<img src="./assets/configuration-ios-addViewControllerToStoryboard.png" height="350" />
299</details>
300
3013. Add an `Image View` to the `View Controller`:
302   - first remove other `View` element from `View Controller`,
303   - open `Library` (`+` button on the top-right),
304   - find `Image View` element,
305   - drag-and-drop it as a `View Controller` child in view hierarchy inspector.
306
307<details>
308 <summary>Show image with details</summary>
309<img src="./assets/configuration-ios-addImageViewToStoryboard.png" height="350" />
310</details>
311
3124. Set `Storyboard ID` to `SplashScreenViewController`:
313   - select `View Controller` in view hierarchy inspector,
314   - navigate to `Identity Inspector` in the right panel,
315   - and set `Storyboard ID` to `SplashScreenViewController`.
316
317<details>
318 <summary>Show image with details</summary>
319<img src="./assets/configuration-ios-addStoryboardID.png" height="350" />
320</details>
321
3225. Tick `Is Initial View Controller` in `SplashScreenViewController`:
323   - select `View Controller` in view hierarchy inspector,
324   - navigate to `Attributes Inspector` in the right panel,
325   - and tick `Is Initial View Controller` in View Controller section.
326
327<details>
328 <summary>Show image with details</summary>
329<img src="./assets/configuration-ios-tickIsInitialViewController.png" height="350" />
330</details>
331
3326. Configure `Image View` source:
333   - select `Image View` in view hierarchy inspector,
334   - navigate to `Attributes Inspector` in the right panel,
335   - select `SplashScreen` in `Image` parameter).
336
337<details>
338 <summary>Show image with details</summary>
339<img src="./assets/configuration-ios-configureImageView.png" height="350" />
340</details>
341
3427. Configure `Background` of the `Image View`:
343   - select `Image View` in view hierarchy inspector,
344   - navigate to `Attributes Inspector` in the right panel,
345   - configure `Background` parameter:
346     - To enter a `#RRGGBB` value you need to select `Custom` option and in the `Colors Popup` that appeared you need to navigate to the second tab and choose `RGB Sliders` from dropdown select.
347
348<details>
349 <summary>Show image with details</summary>
350<img src="./assets/configuration-ios-selectBackgroundColor.png" height="350" />
351</details>
352
353#### �� Select `Content Mode` for the `ImageView` in `SplashScreen.storyboard`
354
355This is how your image will be displayed on the screen.
356
3571. Open `SplashScreen.storyboard` and select `Image View` from `View Controller`.
3582. Navigate to `Attributes Inspector` in the right panel and locate `Content Mode`.
3593. Select one of the following:
360   - `Aspect Fit` to obtain [CONTAIN resize mode](#contain-resize-mode),
361   - `Aspect Fill` to obtain [COVER resize mode](#cover-resize-mode).
3624. You can always choose other options to achieve different image positioning and scaling.
363
364<details>
365 <summary>Show image with details</summary>
366<img src="./assets/configuration-ios-selectImageViewContentMode.png" height="350" />
367</details>
368
369#### �� Mark `SplashScreen.storyboard` as the LaunchScreen
370
371The newly created `SplashScreen.storyboard` needs to be marked as the `Launch Screen File` in your Xcode project in order to be presented from the very beginning of your application launch.
372
3731. Select your project in `Project Navigator`
3742. Select your project name from `TARGETS` panel and navigate to `General` tab.
3753. Locate `App Icons and Launch Images` section and `Launch Screen File` option.
3764. Select or enter `SplashScreen` as the value for located option.
377
378<details>
379 <summary>Show image with details</summary>
380<img src="./assets/configuration-ios-selectLaunchScreen.png" height="350" />
381</details>
382
383#### �� (<em>optional</em>) Enable dark mode
384
385##### Provide different background colors
386
387Depending on what iOS version your application is targeting, you have to adjust your native project differently to a obtain working per-appearance splash screen view.
388
389##### I'm targeting iOS 11+
390
391You can take advantage of [`named colors`](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/WhatsNewXcode/xcode_9/xcode_9.html) in your Xcode project.
392
3931. Create a new `Color Set` and customize its values for different color modes:
394   - in your `.xcassets` directory (either create a new `.xcassets` for colors, or reuse an existing one e.g. with images) create `New Color Set` and name it `SplashScreenBackground`,
395   - navigate to `Attributes Inspector` in the right panel and change `Appearance` to `Any, Dark`,
396   - select desired color in `Attributes Inspector` in the right panel for each mode.
397
398<details>
399 <summary>Show image with details</summary>
400<img src="./assets/configuration-ios-createNamedColor.png" height="350" />
401</details>
402
4032. Select created `named color` as the `Background` for the `Image View` in `SplashScreen.storyboard`:
404   - open `SplashScreen.storyboard` and select `Image View` in view hierarchy inspector,
405   - navigate to `Attributes Inspector` in the right panel,
406   - configure `Background` parameter by selecting your created `named color` (that should be listed as `SplashScreenBackground`).
407
408<details>
409 <summary>Show image with details</summary>
410<img src="./assets/configuration-ios-selectNamedColor.png" height="350" />
411</details>
412
413##### I'm targeting iOS version < 11
414
415You cannot use [`named colors`](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/WhatsNewXcode/xcode_9/xcode_9.html) feature in your Xcode project.
416Instead you have to create an additional image set that contains small 1x1px images, each with the desired background color. Then, you'll use this additional image resource as a background in the splash screen view.
417
418You can use this online generator to obtain 1x1px `.png` images with desired colors: http://www.1x1px.me.
419
4201. Create `SplashScreenBackground` `Image Set` with desired background colors for each mode in your `Images.xcassets` directory:
421   - open your `.xcassets` directory with images,
422   - in the content panel add `New image set` and name it `SplashScreenBackground`,
423   - convert this `Image set` to support `Dark Appearance` by navigating to `Attributes Inspector` in the right panel and changing `Appearance` to `Any, Dark`,
424   - provide images with colors for every mode (you can generate color 1x1px images using http://www.1x1px.me).
425
426<details>
427 <summary>Show image with details</summary>
428<img src="./assets/configuration-ios-addSplashScreenBackgroundImages.png" height="250" />
429</details>
430
4312. Update `SplashScreen.storyboard` to consist of a single top-level `View` with two `Image View` subviews (solid-colored image in the background and actual splash screen image in the foreground):
432
433   - open `SplashScreen.storyboard` and replace `Image View` with a plain `View` (search `Library` for it and drag&drop it in place of current `Image View`),
434   - add two
435
4363. Configure first `Image View` (background color):
437   - configure attributes in `Attributes Inspector`:
438     - set `Image` to `SplashScreenBackground` (prepared in previous step),
439     - set `Content Mode` to `Scale To Fill` (color needs to take all available space),
440   - make this subview take all available space in parent view:
441     - open `Add new constraints` bottom menu,
442     - make sure `Constrain to margin` is not checked,
443     - for every input, open the dropdown and select `View` (parent view reference) and set `0` as the value,
444     - once every side is covered (`0` value and parent view reference selected in dropdown) hit `Add 4 Constraints`,
445     - observe that in `View Hierarchy Inspector` constraints are added and `Image View` resized to take whole place of parent view.
446
447<details>
448 <summary>Show image with details</summary>
449<img src="./assets/configuration-ios-createBackgroundImageView.png" height="350" />
450</details>
451
4524. Configure second `Image View` (actual splash screen image):
453   - select second `Image View` and select correct `Image` in `Attributes Inspector` alongside with desired `Content Mode`,
454   - make this subview take all available space in parent view (see previous step).
455
456<details>
457 <summary>Show image with details</summary>
458<img src="./assets/configuration-ios-addConstraintsToImageViews.png" height="350" />
459</details>
460
461##### Provide different splash screen image
462
463You might want to add a separate image for `dark` mode. If the system is switched to `dark` mode, it would pick this different image instead of the normal one and present it in the splash screen view.
464
4651. In your Xcode project open `SplashScreen` (created in previous section).
4662. Convert this asset to support `Dark Appearance`:
467
468- navigate to `Attributes Inspector` in the right panel,
469- locate `Appearances` section and select `Any, Dark`,
470- provide image for `dark mode` by dropping it to the correct box.
471
472<details>
473 <summary>Show image with details</summary>
474<img src="./assets/configuration-ios-addDarkImagesXcassets.png" height="280" />
475</details>
476
477###### Background color when you want to support iOS < 11
478
479If you're targeting a version of iOS < 11 then you cannot use `named color` feature and instead you need to generate images with desired background colors that are going to be used as the background for splash screen view.
480There is this awesome 1x1px png online generator: http://www.1x1px.me (use it to generate two 1x1px images with desired background colors for different color modes).
481
482#### �� (<em>optional</em>) Customize StatusBar
483
484You might want to customize the StatusBar appearance during the time the SplashScreen is being shown.
485
4861. Customize `StatusBar hiding` flag:
487
488- open main project view, select your project name from `TARGETS` panel and navigate to `Info` tab,
489- add or modify `Status bar initially hidden` attribute with desired value.
490
491<details>
492 <summary>Show image with details</summary>
493<img src="./assets/configuration-ios-statusBar-hidden.png" height="350" />
494</details>
495
4962. Customize `StatusBar style` option:
497
498- open main project view, select your project name from `TARGETS` panel and navigate to `Info` tab,
499- add or modify `Status bar style` attribute with desired value.
500
501<details>
502 <summary>Show image with details</summary>
503<img src="./assets/configuration-ios-statusBar-style.png" height="350" />
504</details>
505
506## �� Configure Android
507
508To achieve fully-native splash screen behavior, `expo-splash-screen` needs to be hooked into the native view hierarchy and consume some resources that have to be placed under `/android/app/src/res` directory.
509
510### Manual Configuration
511
5121. [Configure `res/drawable/splashscreen_image.png`](#-configure-resdrawablesplashscreen_imagepng)
5132. [Configure `res/values/colors.xml`](#-configure-resvaluescolorsxml)
5143. [Configure `res/drawable/splashscreen.xml`](#-configure-resdrawablesplashscreenxml)
5154. [Configure `res/values/styles.xml`](#-configure-resvaluesstylesxml)
5165. [Configure `AndroidManifest.xml`](#-configure-androidmanifestxml)
5176. [(<em>optional</em>) Customzine `resizeMode`](#-optional-customize-resizemode)
5187. [(<em>optional</em>) Enable dark mode](#-optional-enable-dark-mode-1)
5198. [(<em>optional</em>) Customize StatusBar](#-customize-statusbar-1)
520
521#### �� Configure `res/drawable/splashscreen_image.png`
522
523You have to provide your splash screen image and place it under the `res/drawable` directory.
524This image will be loaded as soon as Android mounts your application's native view hierarchy.
525
526##### `NATIVE` mode adjustments
527
528If you've overridden `<string name="expo_splash_screen_resize_mode">native</string>` mode in [`res/values/strings.xml`](#-optional-customize-resizemode), you need to do a few additional steps.
529
530In your application's `res` directory you might want to have a number of `drawable-X` sub-directories (where `X` is the different DPI for different devices). They store different versions of images that are picked based on the device's DPI (for more information please see [this official Android docs](https://developer.android.com/training/multiscreen/screendensities#TaskProvideAltBmp)).
531
532To achieve proper scaling of your splash screen image on every device you should have following directories:
533
534- `res/drawable-mdpi` - scale 1x - resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
535- `res/drawable-hdpi` - scale 1.5x - resources for high-density (hdpi) screens (~240dpi).
536- `res/drawable-xhdpi` - scale 2x - resources for extra-high-density (xhdpi) screens (~320dpi).
537- `res/drawable-xxhdpi` - scale 3x - resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
538- `res/drawable-xxxhdpi` - scale 4x - resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi).
539
540Each of directories mentioned above should contain the same `splashscreen_image.png` file, but with a different resolution (pay attention to scale factors).
541
542#### �� Configure `res/values/colors.xml`
543
544This file contains colors that are reused across your application at the native level.
545Update the file with the following content or create one if missing:
546
547```diff
548<resources>
549+ <color name="splashscreen_background">#AABBCC</color> <!-- #AARRGGBB or #RRGGBB format -->
550  <!-- Other colors defined for your application -->
551</resources>
552```
553
554#### �� Configure `res/drawable/splashscreen.xml`
555
556This file contains the description of how the splash screen view should be drawn by the Android system.
557Create the file with the following content:
558
559```diff
560+ <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
561+   <item android:drawable="@color/splashscreen_background"/>
562+ </layer-list>
563```
564
565#### `NATIVE` mode adjustments
566
567If you've overridden `<string name="expo_splash_screen_resize_mode">native</string>` mode in [`res/values/strings.xml`](#-optional-customize-resizemode), you shoulw add:
568
569```diff
570<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
571  <item android:drawable="@color/splashscreen_background"/>
572+ <item>
573+   <bitmap android:gravity="center" android:src="@drawable/splashscreen_image"/>
574+ </item>
575</layer-list>
576```
577
578#### �� Configure `res/values/styles.xml`
579
580Locate your main activity theme in `/android/app/src/res/values/styles.xml` or create one if missing.
581
582```diff
583  <!-- Main activity theme. -->
584  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
585+   <item name="android:windowBackground">@drawable/splashscreen</item> <!-- this line instructs the system to use 'splashscreen.xml' as a background of the whole application -->
586    <!-- Other style properties -->
587  </style>
588```
589
590#### �� Configure `AndroidManifest.xml`
591
592Adjust your application's main `AndroidManifest.xml` to contain an `android:theme` property pointing to the style that contains your splash screen configuration:
593
594```diff
595<manifest xmlns:android="http://schemas.android.com/apk/res/android"
596    package="com.example.myapp">
597
598  ...
599
600  <application ...>
601
602+   <!-- Ensure that 'android:theme' property is pointing to the style containing native splash screen reference - see 'styles.xml' -->
603    <activity
604      android:name=".MainActivity"
605+     android:theme="@style/AppTheme"
606      ...
607    >
608      ...
609    </activity>
610  </application>
611
612</manifest>
613```
614
615#### �� (<em>optional</em>) Customize `resizeMode`
616
617The default image [`resizeMode`](https://github.com/expo/expo/tree/%40kudo/modularize-expo-splash-screen/packages/expo-splash-screen#built-in-splash-screen-image-resize-modes) is [`CONTAIN`](https://github.com/expo/expo/tree/%40kudo/modularize-expo-splash-screen/packages/expo-splash-screen#contain-resize-mode). If you want to have different `resizeMode`, you need to override in `res/values/strings.xml`.
618
619```diff
620--- a/android/app/src/main/res/values/strings.xml
621+++ b/android/app/src/main/res/values/strings.xml
622 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
623 <resources>
624   <string name="app_name">sdk42</string>
625+  <string name="expo_splash_screen_resize_mode">contain|cover|native</string>
626</resources>
627```
628
629#### �� (<em>optional</em>) Enable dark mode
630
631##### Provide different background colors - `res/values-night/colors.png`
632
633If you want to have different background colors in your splash screen depending on the system color mode, you need to create a similar file to `colors.xml`, but in the directory `res/values-night`.
634Values in this file are going to picked by the system when it is switched to `dark` mode.
635
636```diff
637<resources>
638+ <color name="splashscreen_background">#AABBCC</color> <!-- #AARRGGBB or #RRGGBB format -->
639</resources>
640```
641
642##### Provide different splash screen image - `res/drawable-night/splashscreen_image.png`
643
644You might want to provide a separate splash screen image for dark mode usage, and place it under the `res/drawable-night` directory with exactly the same name as the normal one.
645This step is optional, because you might want to have the same image in both `light` and `dark` modes (e.g. you have just a light-themed logo and you want to have different background colors in different modes).
646
647#### �� (<em>optional</em>) Customize StatusBar
648
649You might want to customize the StatusBar appearance during the time the SplashScreen is being shown.
650
6511. Customize `StatusBar hiding` flag
652
653To have the StatusBar completely hidden you need to update your `res/values/styles.xml` file with the following entry (to prevent StatusBar from hiding either remove this entry or enter `false` as the value):
654
655```diff
656  <!-- Main/SplashScreen activity theme. -->
657  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
658    <item name="android:windowBackground">@drawable/splashscreen</item>
659+   <item name="android:windowFullscreen">true</item>
660    <!-- Other style properties -->
661  </style>
662```
663
664If you have multiple `styles.xml` files located in different directories containing exactly the same `style` entry (e.g. in `res/values-night`, `res/values-night-v23`, etc.), be sure to update these files accordingly.
665
666Read more about `android:windowFullscreen` flag in [official Android documentation](https://developer.android.com/reference/android/R.attr#windowFullscreen).
667
6682. Customize `StatusBar style` option
669
670This option is only available for Android devices running Android 6.0 or greater.
671To enforce `light` or `dark` StatusBar style for given system color mode, you have to prepare or update your `res/values-v23/styles.xml` file with the following entry (as of this option being supported since API 23, you have to configure specifically named directory containing separate configuration files):
672
673```diff
674  <!-- Main/SplashScreen activity theme. -->
675  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
676    <item name="android:windowBackground">@drawable/splashscreen</item>
677+   <item name="android:windowLightStatusBar">true|false</item>
678    <!-- Other style properties -->
679  </style>
680```
681
682Available values:
683
684- `true` for having dark-colored icons,
685- `false` for having light-colored icons.
686
687If you have multiple `styles.xml` files located in different directories containing exactly the same `style` entry (e.g. in `res/values-night-v23` (for dark color mode), etc.), be sure to update these files accordingly.
688
689Read more about `android:windowLightStatusBar` flag in [official Android documentation](https://developer.android.com/reference/android/R.attr#windowLightStatusBar).
690
691To read more about Android multi-API-level support see [this official documentation](https://developer.android.com/guide/topics/resources/providing-resources).
692
6933. Customize `StatusBar color` option (a.k.a. `background color` of the StatusBar component)
694
695To achieve custom background color you need to create a new color resource and provide it to the SplashScreen `style` description.
696
697Create new color resource in your `res/values/colors.xml` (if your application supports dark mode, consider adding different color in `res/values-night/colors.xml` file):
698
699```diff
700  <resources>
701    <color name="splashscreen_background">#D0D0C0</color>
702+   <color name="splashscreen_statusbar_color">#(AA)RRGGBB</color> <!-- #AARRGGBB or #RRGGBB format -->
703  </resources>
704```
705
706Update your `res/values/styles.xml` file with the following entry:
707
708```diff
709  <!-- Main/SplashScreen activity theme. -->
710  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
711    <item name="android:windowBackground">@drawable/splashscreen</item>
712+   <item name="android:statusBarColor">@color/splashscreen_statusbar_color</item>
713    <!-- Other style properties -->
714  </style>
715```
716
717If you have multiple `styles.xml` files located in different directories containing exactly the same `style` entry (e.g. in `res/values-night`, `res/values-night-v23`, etc.), be sure to update these files accordingly.
718
719Read more about `android:statusBarColor` option in [official Android documentation](https://developer.android.com/reference/android/R.attr#statusBarColor).
720
7214. Customize `StatusBar translucent` flag
722
723When the StatusBar is translucent, the app will be able to draw under the StatusBar component area.
724
725To make the StatusBar translucent update your `res/values/strings.xml` file with the following content:
726
727```diff
728--- a/android/app/src/main/res/values/strings.xml
729+++ b/android/app/src/main/res/values/strings.xml
730 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
731 <resources>
732   <string name="app_name">sdk42</string>
733+  <string name="expo_splash_screen_status_bar_translucent">true</string>
734</resources>
735```
736
737## �� Contributing
738
739Contributions are very welcome! Please refer to guidelines described in the [contributing guide](https://github.com/expo/expo#contributing).
740
741## ❓ Known issues
742
743### iOS caching
744
745Splash Screens on iOS apps can sometimes encounter a caching issue where the previous image will flash before showing the new, intended image. When this occurs, we recommend you try power cycling your device and uninstalling and re-installing the application. However, the caching sometimes can persist for a day or two so be patient if the aforementioned steps were unable to resolve the issue.
746
747### `NATIVE` mode pushes splash image up a little bit
748
749See [`NATIVE`](#native-resize-mode) mode preview above.
750
751> We are aware of this issue and unfortunately haven't been able to provide a solution as of yet. This is on our immediate roadmap...
752
753## ⬆️ Migrate from old versions
754
755### Migrate from expo-splash-screen < 0.12.0
756
757We try to keep changes backward compatible, the code for `expo-splash-screen` will still work as it used to be. However, if you are going to migrate as new style API, here are the steps:
758
7591. Migrate your project from react-native-unimodules to expo-modules-core
7602. Remove expo-splash-screen code from MainActivity
761
762```diff
763--- a/android/app/src/main/java/com/helloworld/MainActivity.java
764+++ b/android/app/src/main/java/com/helloworld/MainActivity.java
765 import com.facebook.react.ReactRootView;
766 import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
767
768-import expo.modules.splashscreen.singletons.SplashScreen;
769-import expo.modules.splashscreen.SplashScreenImageResizeMode;
770-
771 public class MainActivity extends ReactActivity {
772   @Override
773   protected void onCreate(Bundle savedInstanceState) {
774     // This is required for expo-splash-screen.
775     setTheme(R.style.AppTheme);
776     super.onCreate(null);
777-    // SplashScreen.show(...) has to be called after super.onCreate(...)
778-    SplashScreen.show(this, SplashScreenImageResizeMode.CONTAIN, ReactRootView.class, false);
779   }
780```
781
7823. Override default `resizeMode` and `statusBarTranslucent` in stings.xml
783
784```diff
785--- a/android/app/src/main/res/values/strings.xml
786+++ b/android/app/src/main/res/values/strings.xml
787 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
788 <resources>
789   <string name="app_name">sdk42</string>
790+  <string name="expo_splash_screen_resize_mode">contain</string>
791+  <string name="expo_splash_screen_status_bar_translucent">false</string>
792</resources>
793```
794
795## �� Hall Of Fame
796
797This module is based on a solid work from (many thanks for that ��):
798
799- [react-native-splash-screen](https://github.com/crazycodeboy/react-native-splash-screen)
800- [react-native-bootsplash](https://github.com/zoontek/react-native-bootsplash)
801- [react-native-make](https://github.com/bamlab/react-native-make)
802