• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Window Metadata Configuration
2<!--Kit: ArkUI-->
3<!--Subsystem: Window-->
4<!--Owner: @waterwin-->
5<!--Designer: @nyankomiya-->
6<!--Tester: @qinliwen0417-->
7<!--Adviser: @ge-yafang-->
8
9## metadata
10
11The **metadata** tag represents custom metadata of a HAP. The tag value is an array and contains three subtags: **name**, **value**, and **resource**.
12
13**Table 1** metadata tag description
14
15| Subtag| Description| Data Type| Optional|
16| -------- | -------- | -------- | -------- |
17| name | Name of the data item. The value is a string with a maximum of 255 bytes.| String| Optional, defaults to an empty array|
18| value | Value of the data item. The value is a string with a maximum of 255 bytes.| String| Optional, defaults to an empty array|
19| resource | Custom data, which is a resource index. The value is a string with a maximum of 255 bytes. For example, **$profile:shortcuts_config** indicates that the data points to the **/resources/base/profile/shortcuts_config.json** file.| String| Optional, defaults to an empty array|
20
21Below are several use cases and examples for the **metadata** tag. You can customize the settings based on service requirements.
22
231. Use the **metadata** tag to configure the default size and position (in vp) of the main window. The following **name** values are available:
24
25    * **ohos.ability.window.height**: specifies the default height of the main window. **value** indicates the height.
26    * **ohos.ability.window.width**: specifies the default width of the main window. **value** indicates the width.
27    * **ohos.ability.window.left**: specifies the default left position of the main window. **value** indicates the configuration format: alignment mode +/- offset. The alignment mode can be **center**, **left**, or **right**. The default value is **left**. It can be omitted when the offset is **0**.
28    * **ohos.ability.window.top**: specifies the default top position of the main window. **value** indicates the configuration format: alignment mode +/- offset. The alignment mode can be **center**, **top**, or **bottom**. The default value is **top**. If both the alignment mode and offset are omitted, the default stacking specifications are used.
29
302. Use the **metadata** tag to configure whether to remove the starting window. Set **name** to **enable.remove.starting.window**, and set **value** to **true** to remove the starting window, or to **false** to keep it. The default value is **false**.
31
323. Use the **metadata** tag to configure whether the main window is maximized upon startup. Set **name** to **ohos.ability.window.isMaximize**, and set **value** to **true** to maximize the main window upon startup, or to **false** to start in a non-maximized state. The default value is **false**. This configuration has the following restrictions:
33
34    * The configuration takes effect only on PCs/2-in-1 devices.
35    * If the **supportWindowModes** property in [startOptions](../reference/apis-ability-kit/js-apis-app-ability-startOptions.md) is used, the **FULL_SCREEN** option must be configured. In this case, the **metadata** tag can be used to configure the main window to start maximized; otherwise, it does not take effect.
36    * If the **supportWindowMode** property in the [module.json5](abilities in../quick-start/module-configuration-file.md) file is used, the **fullscreen** option must be configured. In this case, the **metadata** tag can be used to configure the main window to start maximized; otherwise, it does not take effect.
37    * The priorities of the main window display settings are as follows: full-screen display > using [startOptions](../reference/apis-ability-kit/js-apis-app-ability-startOptions.md) to specify the size and position > using [setWindowRectAutoSave()](../reference/apis-arkui/arkts-apis-window-WindowStage.md#setwindowrectautosave14) to enable window size memory > using the **metadata** tag to configure maximization > using the **metadata** tag to configure the size and position. You can configure full-screen display in any of the following ways:
38        1. Set the **windowMode** property in [startOptions](../reference/apis-ability-kit/js-apis-app-ability-startOptions.md) to **WINDOW_MODE_FULLSCREEN**.
39        2. Set the **supportWindowModes** property in [startOptions](../reference/apis-ability-kit/js-apis-app-ability-startOptions.md) only to **FULL_SCREEN**.
40        3. Set the **supportWindowMode** property in [module.json5](../quick-start/module-configuration-file.md#abilities) only to **fullscreen**.
41
424. Use the **metadata** tag to configure the supported window modes in [free windows](https://developer.huawei.com/consumer/en/doc/design-guides/pad-0000001823654157#section1768267204717) mode. Set **name** to **ohos.ability.window.SupportWindowModeInFreeWindow**, and set **value** to **fullscreen** (full-screen mode), **split** (split-screen mode), **floating** (floating window mode), or any of their combinations (separated by commas, with no space), for example, **fullscreen,split**. This configuration takes effect only on tablets and PCs/2-in-1 devices.
43
44   In free windows mode, the supported window modes can be configured using multiple methods. The configuration priorities are as follows: using [SetSupportedWindowModes](../reference/apis-arkui/arkts-apis-window-WindowStage.md#setsupportedwindowmodes15) to configure the window modes > using **StartAbility** to configure the **SupportWindowMode** property in [StartOption](../reference/apis-ability-kit/js-apis-app-ability-startOptions.md#startoptions) > using the **metadata** tag to configure the window modes > configuring the **SupportWindowMode** property in the [abilities tag](../quick-start/module-configuration-file.md#abilities) of the **module.json5** file.
45
46   In non-free windows mode, only the **SupportWindowMode** property in the **abilities** tag of the **module.json5** file can be used to configure the window modes. Other methods do not take effect.
47
48<!--Del-->
495. Use the **metadata** tag to configure right-angle corners for the main window. Set **name** to **ohos.ability.window.isRightAngle**, and set **value** to **true** for right-angle corners, or to **false** for rounded corners. The default value is **false**. This configuration takes effect only for system applications on PCs/2-in-1 devices.<!--DelEnd-->
50
51
52```json
53{
54  "module": {
55    "abilities": [{
56      "metadata": [{
57        "name": "ability_metadata",
58        "value": "a test demo for ability",
59        "resource": "$profile:config_file"
60      },
61      {
62        "name": "ability_metadata_2",
63        "value": "a string test",
64        "resource": "$profile:config_file"
65      },
66      {
67        "name": "ohos.ability.window.height",
68        "value": "987"
69      },
70      {
71        "name": "ohos.ability.window.width",
72        "value": "1300"
73      },
74      {
75        "name": "ohos.ability.window.left",
76        "value": "right-50"
77      },
78      {
79        "name": "ohos.ability.window.top",
80        "value": "center+50"
81      },
82      {
83        "name": "ohos.ability.window.isMaximize",
84        "value": "true"
85      },
86      {
87        "name": "enable.remove.starting.window",
88        "value": "true"
89      }],
90    }],
91
92    "extensionAbilities": [{
93      "metadata": [{
94        "name": "extensionAbility_metadata",
95        "value": "a test for extensionAbility",
96        "resource": "$profile:config_file"
97      },
98      {
99        "name": "extensionAbility_metadata_2",
100        "value": "a string test",
101        "resource": "$profile:config_file"
102      },
103      {
104        "name": "ohos.ability.window.SupportWindowModeInFreeWindow",
105        "value": "fullscreen,split,floating",
106      }],
107    }]
108  }
109}
110```
111