@@ -56,25 +56,21 @@ In the stage model, the main window of an application is created and maintained
### How to Develop
1. Obtain the main window.
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.
3. Load content for the main window.
Call `loadContent` to load the page content to the main window.
```ts
importAbilityfrom'@ohos.application.Ability'
classMainAbilityextendsAbility{
onWindowStageCreate(windowStage){
// 1. Obtain the main window of the application.
varwindowClass=null;
letwindowClass=null;
windowStage.getMainWindow((err,data)=>{
if(err.code){
console.error('Failed to obtain the main window. Cause: '+JSON.stringify(err));
...
...
@@ -83,7 +79,7 @@ class MainAbility extends Ability {
windowClass=data;
console.info('Succeeded in obtaining the main window. Data: '+JSON.stringify(data));
// 2. Set the touchable property of the main window.
console.error('Failed to create the subwindow. Cause: '+JSON.stringify(err));
...
...
@@ -210,7 +201,6 @@ 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.
2. Implement the immersive effect. You can use any of the following methods:
...
...
@@ -219,17 +209,15 @@ To create a better video watching and gaming experience, you can use the immersi
- 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.
```ts
importAbilityfrom'@ohos.application.Ability'
classMainAbilityextendsAbility{
onWindowStageCreate(windowStage){
// 1. Obtain the main window of the application.
varwindowClass=null;
letwindowClass=null;
windowStage.getMainWindow((err,data)=>{
if(err.code){
console.error('Failed to obtain the main window. Cause: '+JSON.stringify(err));
...
...
@@ -239,7 +227,7 @@ To create a better video watching and gaming experience, you can use the immersi
console.info('Succeeded in obtaining the main window. Data: '+JSON.stringify(data));
// 2. Use method 1 to implement the immersive effect.
console.error('Failed to set the system bar properties. Cause: '+JSON.stringify(err));
return;
...
...
@@ -312,14 +300,11 @@ 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).
> **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":{
...
...
@@ -339,15 +324,12 @@ 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.
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.
5. Destroy the floating window.
...
...
@@ -362,8 +344,8 @@ A floating window is created based on an existing task. It is always displayed i