ionic capacitor splash screen spinner
To add a splash screen spinner in Ionic Capacitor, you can follow these steps:
First, locate the
resources
folder in your Ionic project's root directory. If it doesn't exist, you can create it manually.Inside the
resources
folder, create a new folder calledandroid
if you are targeting Android, orios
if you are targeting iOS.Within the appropriate platform folder (
android
orios
), create another folder calledsplash
.Now, you need to add your splash screen image to the
splash
folder. Make sure the image file is in the correct format and resolution for your target platform. For example, for Android, you can use a 9-patch image format, while for iOS, you can use a PNG file with specific dimensions.After adding the splash screen image, you need to configure the splash screen preferences in the
capacitor.config.json
file. Open this file located in the root directory of your Ionic project.Inside the
plugins
section of thecapacitor.config.json
file, add the following configuration for the splash screen:
"plugins": {
"SplashScreen": {
"launchShowDuration": 0,
"launchAutoHide": false,
"backgroundColor": "#ffffff",
"androidSplashResourceName": "splash",
"showSpinner": true,
"spinnerColor": "#000000"
}
}
Make sure to adjust the values according to your requirements. The showSpinner
property is set to true
to display the spinner, and the spinnerColor
property sets the color of the spinner.
Save the
capacitor.config.json
file.Finally, run the command
npx cap sync
to synchronize the splash screen configuration with your native project.
Now, when you launch your Ionic app, the splash screen with the spinner should be displayed according to the configuration you set.