@@ -21,7 +21,7 @@ The table below lists the common APIs used for application window development. F
| Instance| API| Description|
| -------- | -------- | -------- |
| Window static method| createWindow(config: Configuration, callback: AsyncCallback\<Window>): void | Creates a subwindow.<br>**config** specifies the parameters used for creating the window.|
| Window static method| findWindow(id: string, callback: AsyncCallback<Window>): void | Finds a window based on the ID.|
| Window static method| findWindow(name: string): Window | Finds a window based on the name.|
| Window | SetUIContent(path: string, callback: AsyncCallback<void>): void | Loads the page content to this window.|
| Window | setWindowBackgroundColor(color: string, callback: AsyncCallback<void>): void | Sets the background color for this window.|
...
...
@@ -62,14 +62,11 @@ You can create a subwindow, such as a dialog box, and set its properties.
windowClass=data;
});
// Method 2: Find a subwindow.
window.findWindow("subWindow",(err,data)=>{
if(err.code){
console.error('Failed to find the subWindow. Cause: '+JSON.stringify(err));
return;
}
console.info('Succeeded in finding subWindow. Data: '+JSON.stringify(data));
windowClass=data;
});
try{
windowClass=window.findWindow('subWindow');
}catch(exception){
console.error('Failed to find the Window. Cause: '+JSON.stringify(exception));
}
```
2. Set the properties of the subwindow.
...
...
@@ -154,7 +151,7 @@ To create a better video watching and gaming experience, you can use the immersi
letmainWindowClass=null;
// Obtain the main window.
window.getLastWindow((err,data)=>{
window.getLastWindow(this.context,(err,data)=>{
if(err.code){
console.error('Failed to get the subWindow. Cause: '+JSON.stringify(err));
return;
...
...
@@ -164,7 +161,7 @@ To create a better video watching and gaming experience, you can use the immersi
});
```
2. Implement the immersive effect. You can use any of the following methods:
2. Implement the immersive effect. You can use either of the following methods:
- Method 1: Call **setWindowSystemBarEnable** to hide the navigation bar and status bar.
- Method 2: Call **setWindowLayoutFullScreen** 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.
@@ -49,7 +49,7 @@ 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 a**UIAbility** instance. In the **onWindowStageCreate** callback of the **UIAbility** instance, use **WindowStage** to obtain the main window of the application and set its properties.
### How to Develop
...
...
@@ -66,41 +66,41 @@ In the stage model, the main window of an application is created and maintained
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.
letwindowClass=null;
windowStage.getMainWindow((err,data)=>{
if(err.code){
console.error('Failed to obtain the main window. Cause: '+JSON.stringify(err));
return;
}
windowClass=data;
console.info('Succeeded in obtaining the main window. Data: '+JSON.stringify(data));
// 2. Set the touchable property of the main window.
@@ -211,7 +211,7 @@ To create a better video watching and gaming experience, you can use the immersi
Call **getMainWindow** to obtain the main window of the application.
2. Implement the immersive effect. You can use any of the following methods:
2. Implement the immersive effect. You can use either of the following methods:
- Method 1: Call **setWindowSystemBarEnable** to hide the navigation bar and status bar.
- Method 2: Call **setWindowLayoutFullScreen** to enable the full-screen mode for the main window layout. Call **setWindowSystemBarProperties** 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.
...
...
@@ -220,9 +220,9 @@ To create a better video watching and gaming experience, you can use the immersi
Call **loadContent** to load the content to the immersive window.
```ts
importAbilityfrom'@ohos.application.Ability'
importUIAbilityfrom'@ohos.app.ability.UIAbility';
classMainAbilityextendsAbility{
exportdefaultclassEntryAbilityextendsUIAbility{
onWindowStageCreate(windowStage){
// 1. Obtain the main window of the application.
letwindowClass=null;
...
...
@@ -303,7 +303,7 @@ A floating window is created based on an existing task. It is always displayed i
"name":"ohos.permission.SYSTEM_FLOAT_WINDOW",
"usedScene":{
"abilities":[
"MainAbility"
"EntryAbility"
],
"when":"inuse"
}
...
...
@@ -330,11 +330,11 @@ A floating window is created based on an existing task. It is always displayed i
When the floating window is no longer needed, you can call **destroyWindow** to destroy it.