Read the original article:How to use window manager and what is it ?
Context
The Window module provides a mechanism for displaying multiple application UIs and allowing the end user to interact with them on the same physical screen.
- For application developers, the Window module provides APIs for UI display and user interaction.
- For end users, the Window module provides a way to control application UIs.
- For the entire operating system, the Window module provides logic for application UI management.
Description
The Window module has the following features:
- Provides a Window object to hold application and system UIs. You can load your application UIs through the window to display them to the end user.
- Maintains the window relationship (overlay layers and positions). Different types of application and system windows have different default positions and overlay layers (z-index). End users can adjust the position and overlay layer of a window within a certain range.
- Provides window decoration. Window decoration refers to the title bar and border of a window. The title bar usually provides the Maximize, Minimize, and Close buttons and has the default click behavior. The border can be dragged to relocate or resize the window. Window decoration is a system-level default behavior. You can enable or disable window decoration without paying attention to the implementation at the UI code layer.
- Provides window animations. When a window is displayed, hidden, or switched, an animation is usually used to smooth the interaction process. This is the default behavior for application windows. You do not need to set or modify the code.
- Provides guidance for input event distribution. Events are distributed based on the window status and focus. Touch and mouse events are distributed based on the window position and size, and keyboard events are distributed to the focused window. You can call APIs provided by the Window module to set whether a window is touchable and can gain focus.
Solution/Approach
import window from '@ohos.window'
import { common } from '@kit.AbilityKit'
@Entry
@Component
struct FullscreenExample {
  build() {
    Column() {
      Text('Full Page and set brightness')
    }.onAppear(() => {
      let context = getContext(this) as common.UIAbilityContext
      window.getLastWindow(context).then(win => {
        win.setWindowBrightness(1.0)
        win.setWindowLayoutFullScreen(true)
      })
    })
  }
}
Key Takeaway
| Instance | API | Description | 
| Window static method | createWindow(config: Configuration, callback: AsyncCallback): void | Creates a child window. config: parameters used for creating the window. | 
| Window static method | findWindow(name: string): Window | Finds a window based on the name. | 
| Window | setUIContent(path: string, callback: AsyncCallback): void | Loads the content of a page, with its path in the current project specified, to this window. path: path of the page from which the content will be loaded. The path is configured in the config.json<.strong> file of the project in the FA model. | 
| Window | moveWindowTo(x: number, y: number, callback: AsyncCallback): void | Moves this window. | 
| Window | setWindowBrightness(brightness: number, callback: AsyncCallback): void | Sets the brightness for this window. | 
| Window | resize(width: number, height: number, callback: AsyncCallback): void | Changes the window size. | 
| Window | setWindowLayoutFullScreen(isLayoutFullScreen: boolean): Promise | Sets whether to enable the full-screen mode for the window layout. | 
| Window | setWindowSystemBarEnable(names: Array<'status'|'navigation'>): Promise | Sets whether to display the status bar and navigation bar in this window. | 
| Window | setWindowSystemBarProperties(systemBarProperties: SystemBarProperties): Promise | Sets the properties of the status bar and navigation bar in this window. systemBarProperties: properties of the status bar and navigation bar. | 
| Window | showWindow(callback: AsyncCallback): void | Shows this window. | 
| Window | on(type: 'touchOutside', callback: Callback): void | Enables listening for touch events outside this window. | 
| Window | destroyWindow(callback: AsyncCallback): void | Destroys this window. | 
 

 
    
Top comments (0)