@@ -32,7 +32,7 @@ The table below lists the common APIs used for application window development. F
| WindowStage | getMainWindow(callback: AsyncCallback<Window>): void | Obtains the main window of this window stage.<br>This API can be used only in the stage model.|
| WindowStage | loadContent(path: string, callback: AsyncCallback<void>): void | Loads the page content to the main window in this window stage.<br>This API can be used only in the stage model.|
| WindowStage | createSubWindow(name: string, callback: AsyncCallback<Window>): void | Creates a subwindow.<br>This API can be used only in the stage model.|
| Window | loadContent(path: string, callback: AsyncCallback<void>): void | Loads the page content to this window.|
| Window | setBackgroundColor(color: string, callback: AsyncCallback<void>): void | Sets the background color for this window.|
| Window | setBrightness(brightness: number, callback: AsyncCallback<void>): void | Sets the brightness for this window.|
...
...
@@ -42,7 +42,7 @@ The table below lists the common APIs used for application window development. F
| Window | setFullScreen(isFullScreen: boolean, callback: AsyncCallback<void>): void | Sets whether to enable the full-screen mode for this window.|
| Window | setLayoutFullScreen(isLayoutFullScreen: boolean, callback: AsyncCallback<void>): void | Sets whether to enable the full-screen mode for the window layout. |
| Window | setSystemBarEnable(names: Array<'status'\|'navigation'>): Promise<void> | Sets whether to display the status bar and navigation bar in this window.|
| Window | setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void | Sets the properties of the status bar and navigation bar in this window.<br>`systemBarProperties`: properties of the status bar and navigation bar.|
| Window | setSystemBarProperties(systemBarProperties: SystemBarProperties, callback: AsyncCallback<void>): void | Sets the properties of the status bar and navigation bar in this window.<br>**systemBarProperties**: properties of the status bar and navigation bar.|
| Window | show(callback: AsyncCallback\<void>): void | Shows this window.|
| Window | on(type: 'touchOutside', callback: Callback<void>): void | Enables listening for click events outside this window.|
| Window | destroy(callback: AsyncCallback<void>): void | Destroys this window.|
...
...
@@ -50,19 +50,22 @@ The table below lists the common APIs used for application window development. F
## Setting the Main Window of an Application
In the stage model, the main window of an application is created and maintained by an `Ability` instance. In the `onWindowStageCreate` callback of the `Ability` instance, use `WindowStage` to obtain the main window of the application and set its properties.
In the stage model, the main window of an application is created and maintained by an **Ability** instance. In the **onWindowStageCreate** callback of the **Ability** instance, use **WindowStage** to obtain the main window of the application and set its properties.
### How to Develop
1. Obtain the main window.
Call `getMainWindow` to obtain the main window of the application.
Call **getMainWindow** to obtain the main window of the application.
2. Set the properties of the main window.
You can set multiple properties of the main window, such as the background color, brightness, and whether the main window is touchable. The code snippet below uses the `touchable` property as an example.
You can set multiple properties of the main window, such as the background color, brightness, and whether the main window is touchable. The code snippet below uses the **touchable** property as an example.
3. Load content for the main window.
Call `loadContent` to load the page content to the main window.
Call **loadContent** to load the page content to the main window.
```ts
importAbilityfrom'@ohos.application.Ability'
...
...
@@ -109,19 +112,23 @@ You can create an application subwindow, such as a dialog box, and set its prope
### How to Develop
1. Create or obtain a subwindow.
Call `createSubWindow` to create a subwindow.
Call `getSubWindow` to obtain a subwindow.
Call **createSubWindow** to create a subwindow.
Call **getSubWindow** to obtain a subwindow.
2. Set the properties of the subwindow.
After the subwindow is created, you can set its properties, such as the size, position, background color, and brightness.
3. Load content for the subwindow and show it.
Call `loadContent` and `show` to load and display the content in the subwindow.
Call **loadContent** and **show** to load and display the content in the subwindow.
4. Destroy the subwindow.
When the subwindow is no longer needed, you can call `destroy` to destroy it.
When the subwindow is no longer needed, you can call **destroy** to destroy it.
```ts
importAbilityfrom'@ohos.application.Ability'
...
...
@@ -201,16 +208,18 @@ To create a better video watching and gaming experience, you can use the immersi
### How to Develop
1. Obtain the main window.
Call `getMainWindow` to obtain the main window of the application.
Call **getMainWindow** to obtain the main window of the application.
2. Implement the immersive effect. You can use any of the following methods:
- Method 1: Call `setFullScreen` to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
- Method 2: Call `setSystemBarEnable` to hide the navigation bar and status bar.
- Method 3: Call `setLayoutFullScreen` to enable the full-screen mode for the main window layout. Call `setSystemProperties` to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
- Method 1: Call **setFullScreen** to set the main window to be displayed in full screen. In this case, the navigation bar and status bar are hidden.
- Method 2: Call **setSystemBarEnable** to hide the navigation bar and status bar.
- Method 3: Call **setLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setSystemProperties** to set the opacity, background color, text color, and highlighted icon of the navigation bar and status bar to ensure that their display effect is consistent with that of the main window.
3. Load content for the immersive window and show it.
Call `loadContent` and `show` to load and display the content in the immersive window.
Call **loadContent** to load the content to the immersive window.
```ts
importAbilityfrom'@ohos.application.Ability'
...
...
@@ -256,9 +265,6 @@ To create a better video watching and gaming experience, you can use the immersi
letsysBarProps={
statusBarColor:'#ff00ff',
navigationBarColor:'#00ff00',
// The following properties are supported since API version 7.
isStatusBarLightIcon:false,
isNavigationBarLightIcon:false,
// The following properties are supported since API version 8.
statusBarContentColor:'#ffffff',
navigationBarContentColor:'#ffffff'
...
...
@@ -278,14 +284,6 @@ To create a better video watching and gaming experience, you can use the immersi
return;
}
console.info('Succeeded in loading the content. Data: '+JSON.stringify(data));
// 3. Show the immersive window.
windowStage.show((err,data)=>{
if(err.code){
console.error('Failed to show the window. Cause:'+JSON.stringify(err));
return;
}
console.info('Succeeded in showing the window. Data: '+JSON.stringify(data));
});
});
}
};
...
...
@@ -300,11 +298,13 @@ A floating window is created based on an existing task. It is always displayed i
### How to Develop
1. Apply for permissions.
To create a floating window (of the `WindowType.TYPE_FLOAT` type), you must configure the `ohos.permission.SYSTEM_FLOAT_WINDOW` permission in the `requestPermissions` field of the `module.json5` file. For details about the file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
To create a floating window (of the **WindowType.TYPE_FLOAT** type), you must configure the **ohos.permission.SYSTEM_FLOAT_WINDOW** permission in the **requestPermissions** field of the **module.json5** file. For details about the file, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
> **NOTE**
>
> If the task for creating the floating window is reclaimed by the system, the floating window will no longer be displayed. If you want the floating window to be displayed in such a case, apply for a [continuous task](../task-management/background-task-overview.md).
```json
{
"module":{
...
...
@@ -324,17 +324,20 @@ A floating window is created based on an existing task. It is always displayed i
```
2. Create a floating window.
Call `window.create` to create a floating window.
Call **window.create** to create a floating window.
3. Set properties for the floating window.
After the floating window is created, you can set its properties, such as the size, position, background color, and brightness.
4. Load content for the floating window and show it.
Call `loadContent` and `show` to load and display the content in the floating window.
Call **loadContent** and **show** to load and display the content in the floating window.
5. Destroy the floating window.
When the floating window is no longer needed, you can call `destroy` to destroy it.
When the floating window is no longer needed, you can call **destroy** to destroy it.
```ts
importAbilityfrom'@ohos.application.Ability'
...
...
@@ -397,4 +400,4 @@ A floating window is created based on an existing task. It is always displayed i