DEV Community

HarmonyOS
HarmonyOS

Posted on

How to Prevent the Icon from Displaying When the App Starts Up?

Read the original article:How to Prevent the Icon from Displaying When the App Starts Up?

Context

When the App starts, it defaults to a white background with an icon in the center. Is there a way to configure a custom splash screen?

Description

After attempting to set startWindowIcon to a transparent image and startWindowBackground to a transparent background color, the app still flashes the desktop icon before entering the splash screen. What other configurations are needed?

Picture1.png

Device Version: 5.0.0.126(SP8)

DevEco Studio Version: DevEco Studio 5.0.1 Release Build Version: 5.0.5.310, built on December 11, 2024

SDK Version: OpenHarmony 5.0.1.111

Solution

  • The splash screen is displayed when an application cold starts. Its purpose is to allow the application to respond quickly during a cold start and prioritize the execution of the startup animation (when you click a desktop icon, the window animation immediately starts executing. At this point, the application has not yet started, and there is no content to display, so displaying a splash screen is inevitable. Both Android and iOS have this mechanism).
  • The timing of when the application content finishes rendering depends on the complexity of the application's content itself. The slower the application loads, the longer it will stay on the splash screen.
  • The application only supports configuring the icon and background color of the splash screen. The system will display the splash screen during the application's cold start and remove it after the application has finished loading. The removal timing is entirely dependent on when the application content finishes rendering. In module.json5, there are two fields: startWindowIcon and startWindowBackground, which correspond to the splash screen's icon and background color, respectively.
  • Every UIAbility must have a splash screen, and these two fields are mandatory; otherwise, the compilation will fail.

Currently, using a transparent icon (setting startWindowIcon to transparent will cause the app to briefly flash a white screen during startup). You can try the following solution: Set startWindowIcon to a custom splash screen image and set startWindowBackground to the same background color as your application's image to avoid color differences.

Key Takeaways

  • The splash screen image will be displayed centered at its actual size and will not be stretched.
  • If the splash screen image is larger than the screen's width or height, the overflowing parts will not be displayed
  • no relevant interface to control the display duration of startWindowIcon.

Written by Taskhyn Maksim

Top comments (0)