DEV Community

HarmonyOS
HarmonyOS

Posted on

Status bar color changes when entering and exiting the app

Read the original article:Status bar color changes when entering and exiting the app

Problem Description

The status bar color changes suddenly when entering and exiting the application.

Background Knowledge

  1. setWindowSystemBarProperties is used to set the properties of the navigation bar and status bar in the full-screen main window.
  2. SystemBarProperties includes properties such as background color, text color, whether the icon is highlighted, and icon animation. For adaptation, please refer to How to Implement Status Bar Background Color Immersion.

Troubleshooting Process

Check the code and search setWindowSystemBarProperties globally. It is found that the statusBarColor in SystemBarProperties is set, and the value is not set to transparent color.

let SystemBarProperties: window.SystemBarProperties = {
  statusBarColor: '#000000' 
  ...
}
...
let promise = windowClass.setWindowSystemBarProperties(SystemBarProperties);
Enter fullscreen mode Exit fullscreen mode

Analysis Conclusion

The application changes the background color of the status bar when entering and exiting the application, resulting in a sudden color change.

Solution

Set the statusBarColor value to transparent.

statusBarColor: 'rgba(0, 0, 0, 0)'
Enter fullscreen mode Exit fullscreen mode

Written by Mucahid Kincir

Top comments (0)