The interface layer of the window runs in the application process. It loads the page layout and provides APIs.
The interface layer of the window runs in the application process. It loads the page layout and provides APIs.
By calling these APIs, you can create and destroy a window, set the position and size of a window, and enter the immersive mode (full-screen mode).
By calling these APIs, you can create and destroy a window, set the position and size of a window, and enter the immersive mode (full-screen mode).
...
@@ -22,7 +22,7 @@ For details about the APIs, see [Window](https://gitee.com/openharmony/docs/blob
...
@@ -22,7 +22,7 @@ For details about the APIs, see [Window](https://gitee.com/openharmony/docs/blob
### Creating a Main Window
### Creating a Main Window
Currently, the main window is automatically created when the application is started. The declaration period, hiding, and destruction of the main window are managed by the application.
Currently, the main window is automatically created when the application is started. The declaration period, hiding, and destruction of the main window are managed by the application.
###Creating a Subwindow
###Creating a Subwindow
You can call **create** to create a subwindow. The sample code is as follows:
You can call **create** to create a subwindow. The sample code is as follows:
```
```
...
@@ -87,22 +87,18 @@ After a window object is obtained, you can call **hide** and **destroy** to hide
...
@@ -87,22 +87,18 @@ After a window object is obtained, you can call **hide** and **destroy** to hide
### Enabling the Full-Screen Mode
### Enabling the Full-Screen Mode
After a window object is obtained,
After a window object is obtained, you can call **setFullScreen** to enable the full-screen mode for the window.
- call **setFullScreen** to enable the full-screen mode for the window.
The Window Manager subsystem provides basic capabilities of window and display management. It is the basis for UI display.
The Window Manager subsystem provides basic capabilities of window and display management. It is the basis for UI display.
The Window Manager subsystem enables multiple applications to use the same physical screen for display and interaction. For each application, you only need to implement the interaction interface in the allocated display area. A window acts as a display container of the application interface, and the Window Manager subsystem organizes the interaction interfaces into a form visible to end users.
The Window Manager subsystem enables multiple applications to use the same physical screen for display and interaction. For each application, you need to design the interaction interface in the fixed window area. A window acts as a display container of the application interface, and the Window Manager subsystem organizes the interaction interfaces into a form visible to end users.
## Basic Concepts
## Basic Concepts
**Immersive**
The colors of the application interface, status bar, and navigation bar are the same to achieve the visual integrity.
** Immersive**: The colors of the application interface, status bar, and navigation bar are the same to achieve the visual integrity.
## Working Principles
## Working Principles
To display a UI on a screen, the application and system need to request a window object from the Window Manager subsystem. This object generally represents a rectangular area on the screen and has attributes such as the position, width, height, and overlay layer. The object also loads the root node of the UI framework in the interface. The UI of the application is loaded and displayed in the window through the root node.
To display a UI on a screen, the application and system need to request a window object from the Window Manager subsystem. This object generally represents a rectangular area on the screen and has attributes such as the position, width, height, and overlay layer. The object also loads the root node of the UI framework in the interface. The UI of the application is loaded and displayed in the window through the root node.
## Constraints
Except the **on** and **off** APIs used for callback subscription and unsubscription, all other window APIs are asynchronous interfaces.
| moveTo(x: number, y: number): Promise\<void> | Moves the window position. A positive value of **x** indicates that the window moves to the right, and a positive value of **y** indicates that the window moves downwards.|
| destroy(): Promise\<void> | Destroys the window. |
## 开发步骤
## How to Develop
### 创建主窗口
### Creating a Main Window
在当前模型下,应用启动时会自动创建主窗口,由应用管理窗口的声明周期,隐藏及销毁由应用管理。
Currently, the main window is automatically created when the application is started. The declaration period, hiding, and destruction of the main window are managed by the application.
### 创建子窗口
### Creating a Subwindow
当前可以通过`create`接口创建子窗口。具体示例代码如下:
You can call **create** to create a subwindow. The sample code is as follows:
```
```
import window from '@ohos.window';
import window from '@ohos.window';
...
@@ -37,9 +37,9 @@
...
@@ -37,9 +37,9 @@
});
});
```
```
### 获取窗口对象
### Obtaining a Window Object
-应用内可以通过`getTopWindow`来获取当前应用内最后显示的窗口。具体示例代码如下:
-Call **getTopWindow** to obtain the top window of the application. The sample code is as follows:
```
```
var windowClass = null;
var windowClass = null;
...
@@ -52,7 +52,7 @@
...
@@ -52,7 +52,7 @@
})
})
```
```
-应用内也可以通过`Find`来获取已经创建的子窗口。具体示例代码如下:
-You can also call **find** to obtain created subwindows in the application. The sample code is as follows:
After a window object is obtained, you can call **hide** and **destroy** to hide and destroy the window object, respectively. The sample code is as follows:
```
```
let promise = windowClass.hide();
let promise = windowClass.hide();
...
@@ -85,11 +85,11 @@
...
@@ -85,11 +85,11 @@
})
})
```
```
### 设置沉浸式窗口
### Enabling the Full-Screen Mode
在已经获取到应用窗口对象的前提下,调用`setFullScreen`来设置窗口进入全屏沉浸式。
After a window object is obtained, you can call **setFullScreen** to enable the full-screen mode for the window.
The Window Manager subsystem enables multiple applications to use the same physical screen for display and interaction. For each application, you need to design the interaction interface in the fixed window area. A window acts as a display container of the application interface, and the Window Manager subsystem organizes the interaction interfaces into a form visible to end users.
## 基本概念
## Basic Concepts
**沉浸式**:应用窗口跟状态栏与导航栏颜色一致,视觉上融合。
** Immersive**: The colors of the application interface, status bar, and navigation bar are the same to achieve the visual integrity.
To display a UI on a screen, the application and system need to request a window object from the Window Manager subsystem. This object generally represents a rectangular area on the screen and has attributes such as the position, width, height, and overlay layer. The object also loads the root node of the UI framework in the interface. The UI of the application is loaded and displayed in the window through the root node.