openharmony 鸿蒙 arkts-apis-window-i

2025-06-12 浏览 (1)

Interfaces (Others)

NOTE

The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Configuration9+

Describes the parameters for creating a child window or system window.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.WindowManager.WindowManager.Core

NameTypeMandatoryDescription
namestringYesName of the window.
windowTypeWindowTypeYesWindow type.
ctxBaseContextNoCurrent application context. If no value is passed, no context is used.
In the FA model, do not pass in this parameter when creating a child window. Otherwise, an error is reported.
In the stage model, you must pass in this parameter when creating a floating window, modal window, or system window.
displayIdnumberNoID of the current physical screen. If no value is passed, the default value -1 is used. The value must be an integer.
parentIdnumberNoID of the parent window. If no value is passed, the default value -1 is used. The value must be an integer.
decorEnabled12+booleanNoWhether the window decoration is enabled. This parameter is valid only when windowType is set to TYPE_DIALOG. The value true means that the window decoration is enabled, and false means the opposite. The default value is false.
System capability: SystemCapability.Window.SessionManager
title12+stringNoTitle of the window when decorEnabled is set to true. The title display area should not go past the left side of the three-button area of the system. Any part that goes beyond will show as an ellipsis. If this parameter is not set, an empty string is used.
System capability: SystemCapability.Window.SessionManager
defaultDensityEnabled20+booleanNoWhether the window should use the default density of the system. If the default density is used, the window does not change layout when the system display size changes.
If this parameter is set to true for a system window, the window uses the default density and is not affected by setDefaultDensityEnabled() or setCustomDensity() settings for the main window.
If this parameter is set to false, the window does not use the default density and is affected by those settings.
The default value is false.
System capability: SystemCapability.Window.SessionManager

SystemBarProperties

Describes the properties of the status bar and three-button navigation bar. It is used to set the window-level status bar and three-button navigation bar properties.

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeMandatoryDescription
statusBarColorstringNoBackground color of the status bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, '#00FF00' or '#FF00FF00'. The default value is '#66000000'.
System capability: SystemCapability.WindowManager.WindowManager.Core
isStatusBarLightIcon7+booleanNoWhether any icon on the status bar is highlighted. The value true means that the icon is highlighted, and false means the opposite. The default value is false.
System capability: SystemCapability.WindowManager.WindowManager.Core
statusBarContentColor8+stringNoColor of the text on the status bar. After this property is set, the setting of isStatusBarLightIcon is invalid. The default value is '#E5FFFFFF'.
System capability: SystemCapability.WindowManager.WindowManager.Core
navigationBarColorstringNoBackground color of the three-button navigation bar. The value is a hexadecimal RGB or ARGB color code and is case insensitive, for example, '#00FF00' or '#FF00FF00'. The default value is '#66000000'.
System capability: SystemCapability.WindowManager.WindowManager.Core
isNavigationBarLightIcon7+booleanNoWhether any icon on the three-button navigation bar is highlighted. The value true means that the icon is highlighted, and false means the opposite. The default value is false.
System capability: SystemCapability.WindowManager.WindowManager.Core
navigationBarContentColor8+stringNoColor of the text on the three-button navigation bar. After this property is set, the setting of isNavigationBarLightIcon is invalid. The default value is '#E5FFFFFF'.
System capability: SystemCapability.WindowManager.WindowManager.Core
enableStatusBarAnimation12+booleanNoWhether to enable animation for a status bar property change. The value true means to enable animation, and false means the opposite. The default value is false.
System capability: SystemCapability.Window.SessionManager
enableNavigationBarAnimation12+booleanNoWhether to enable animation for a three-button navigation bar property change. The value true means to enable animation, and false means the opposite. The default value is false.
System capability: SystemCapability.Window.SessionManager

StatusBarProperty18+

Describes the properties of the status bar. These properties are returned when you query the status bar's configuration details.

Atomic service API: This API can be used in atomic services since API version 18.

NameTypeMandatoryDescription
contentColorstringYesColor of the text on the status bar. The value is in ARGB format, for example, #E5FFFFFF.
System capability: SystemCapability.Window.SessionManager

SystemBarStyle12+

Describes the properties of the status bar. These properties are valid for the page-level status bar.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.WindowManager.WindowManager.Core

NameTypeRead-OnlyOptionalDescription
statusBarContentColorstringYesYesColor of the text on the status bar. The default value is '#E5FFFFFF'.

Rect7+

Describes the rectangular area of the window.

System capability: SystemCapability.WindowManager.WindowManager.Core

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeReadableWritableDescription
leftnumberYesYesLeft boundary of the rectangle, in px. The value must be an integer.
topnumberYesYesTop boundary of the rectangle, in px. The value must be an integer.
widthnumberYesYesWidth of the rectangle, in px. The value must be an integer.
heightnumberYesYesHeight of the rectangle, in px. The value must be an integer.

AvoidArea7+

Describes the area where the window cannot be displayed, for example, the system bar area, notch, gesture area, and soft keyboard area. Touch events will not be responded in this area.

Pay attention to the following restrictions on this area:

  • The bottom gesture area, apart from the bottom navigation bar area, supports transparent transmission of touch events, and touch and hold events, but not drag events.

  • The gesture area on the left and right sides supports transparent transmission of touch events, touch and hold events, and swipe up and down events, but not drag events.

  • The bottom navigation bar area supports responding to touch events, touch and hold events, and drag events. However, it does not support transparent transmission of events.

System capability: SystemCapability.WindowManager.WindowManager.Core

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeReadableWritableDescription
visible9+booleanYesYesWhether the window can be displayed in the area. The value true means that the window can be displayed in the area, and false means the opposite.
leftRectRectYesYesRectangle on the left of the screen.
topRectRectYesYesRectangle at the top of the screen.
rightRectRectYesYesRectangle on the right of the screen.
bottomRectRectYesYesRectangle at the bottom of the screen.

Size7+

Describes the window size.

System capability: SystemCapability.WindowManager.WindowManager.Core

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeReadableWritableDescription
widthnumberYesYesWindow width, in px. The value must be an integer.
heightnumberYesYesWindow height, in px. The value must be an integer.

RectChangeOptions12+

Describes the value and reason returned upon a window rectangle (position and size) change.

System capability: SystemCapability.Window.SessionManager

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeReadableWritableDescription
rectRectYesYesNew value of the window rectangle.
reasonRectChangeReasonYesYesReason for the window rectangle change.

AvoidAreaOptions12+

Describes the new area where the window cannot be displayed. The new area is returned when the corresponding event is triggered.

System capability: SystemCapability.WindowManager.WindowManager.Core

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeReadableWritableDescription
typeAvoidAreaTypeYesYesType of the new area returned.
areaAvoidAreaYesYesNew area returned.

WindowProperties

Describes the window properties.

System capability: SystemCapability.WindowManager.WindowManager.Core

NameTypeRead-OnlyOptionalDescription
windowRect7+RectNoNoWindow size, which can be obtained from the page lifecycle onPageShow or the application lifecycle onForeground.
Atomic service API: This API can be used in atomic services since API version 11.
drawableRect11+RectNoNoSize of the rectangle that can be drawn in the window. The upper boundary and left boundary are calculated relative to the window. In the stage model, this API must be used after loadContent() or setUIContent() is called to load the page content.
Atomic service API: This API can be used in atomic services since API version 12.
type7+WindowTypeNoNoWindow type.
Atomic service API: This API can be used in atomic services since API version 12.
isFullScreenbooleanNoNoWhether the window is displayed in full-screen mode. The default value is false. The value true means that the window is displayed in full-screen mode, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
isLayoutFullScreen7+booleanNoNoWhether the window is immersive and in full-screen mode (not in floating window or split-screen scenarios). The default value is false. The value true means that the window is immersive and in full-screen mode, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
focusable7+booleanYesNoWhether the window can gain focus. The default value is true. The value true means that the window can gain focus, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
touchable7+booleanYesNoWhether the window is touchable. The default value is true. The value true means that the window is touchable, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
brightnessnumberNoNoScreen brightness. The value is a floating point number in the range [0.0, 1.0], and the value 1.0 means the brightest. If no value is passed, the brightness follows the system. In this case, the obtained brightness value is -1.
Atomic service API: This API can be used in atomic services since API version 11.
dimBehindValue(deprecated)numberNoNoDimness of the window that is not on top. The value is a floating point number in the range [0.0, 1.0], and the value 1.0 means the dimmest.
NOTE
This property is supported since API version 7 and deprecated since API version 9.
Currently, no substitute is available.
isKeepScreenOnbooleanNoNoWhether the screen is always on. The default value is false. The value true means that the screen is always on, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 11.
isPrivacyMode7+booleanNoNoWhether the window is in privacy mode. The default value is false. The value true means that the window is in privacy mode, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
isRoundCorner(deprecated)booleanNoNoWhether the window has rounded corners. The default value is false. The value true means that the window has rounded corners, and false means the opposite.
NOTE
This property is supported since API version 7 and deprecated since API version 9.
Currently, no substitute is available.
isTransparent7+booleanNoNoWhether the window background is transparent. The default value is false. The value true means that the window background is transparent, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
id9+numberYesNoWindow ID. The default value is 0. The value must be an integer.
Atomic service API: This API can be used in atomic services since API version 12.
displayId12+numberYesYesID of the screen where the window is located. By default, the ID of the main screen is returned. The value must be an integer.
Atomic service API: This API can be used in atomic services since API version 12.
name18+stringYesYesWindow name. The default value is an empty string.
Atomic service API: This API can be used in atomic services since API version 18.

DecorButtonStyle14+

Describes the button style of the system decoration bar.

System capability: SystemCapability.Window.SessionManager

Atomic service API: This API can be used in atomic services since API version 14.

NameTypeReadableWritableDescription
colorModeConfigurationConstant.ColorModeYesYesColor mode. Buttons automatically adapt to light colors in dark mode and to dark colors in light mode. If this parameter is not set, they will automatically match the system color mode.
buttonBackgroundSizenumberYesYesSize of the button when it is highlighted. The value ranges from 20 vp to 40 vp. The default value is 28 vp.
spacingBetweenButtonsnumberYesYesSpacing between buttons. The value ranges from 8 vp to 24 vp. The default value is 12 vp.
closeButtonRightMarginnumberYesYesMargin between the rightmost edge of the close button and the window. The value ranges from 6 vp to 22 vp. The default value is 20 vp.
buttonIconSize20+numberYesYesSize of the button icon. The value ranges from 16 vp to 24 vp. The default value is 20 vp.
buttonBackgroundCornerRadius20+numberYesYesRadius of the button background rounded corner. The value ranges from 4 vp to 8 vp. The default value is 4 vp.

WindowLimits11+

Describes the window size limits. You can call setWindowLimits to set the window size limits and call getWindowLimits to obtain the current window size limits.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Window.SessionManager

NameTypeReadableWritableDescription
maxWidthnumberYesYesMaximum window width, in px. The value must be an integer. The default value is 0, indicating that the property does not change. The lower limit is 0, and the upper limit is the maximum width specified by the system.
maxHeightnumberYesYesMaximum window height, in px. The value must be an integer. The default value is 0, indicating that the property does not change. The lower limit is 0, and the upper limit is the maximum height specified by the system.
minWidthnumberYesYesMinimum window width, in px. The value must be an integer. The default value is 0, indicating that the property does not change. The lower limit is 0, and the upper limit is the minimum width specified by the system.
minHeightnumberYesYesMinimum window height, in px. The value must be an integer. The default value is 0, indicating that the property does not change. The lower limit is 0, and the upper limit is the minimum height specified by the system.

TitleButtonRect11+

Describes the rectangle used to hold the minimize, maximize, and close buttons on the title bar. This rectangle is located in the upper right corner of the window.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.Window.SessionManager

NameTypeReadableWritableDescription
rightnumberYesYesRight boundary of the rectangle, in vp. The value must be an integer.
topnumberYesYesTop boundary of the rectangle, in vp. The value must be an integer.
widthnumberYesYesWidth of the rectangle, in vp. The value must be an integer.
heightnumberYesYesHeight of the rectangle, in vp. The value must be an integer.

MoveConfiguration15+

Describes the window movement configuration.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.Window.SessionManager

NameTypeMandatoryDescription
displayIdnumberNoTarget display ID. The value must be an integer. If a non-integer is passed in, the value is rounded down. If this parameter is passed in, the window is positioned relative to the upper left corner of the target display. If this parameter is left empty or the target display ID does not exist, the window is positioned relative to the upper left corner of the current display.

WindowDensityInfo15+

Describes the information about the display density of the screen where the window is located and the window's custom display density. It is a scale factor independent of pixel units, that is, a factor for scaling display size.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.Window.SessionManager

NameTypeReadableWritableDescription
systemDensitynumberYesNoSystem's display size scale factor for the screen where the window is located. The value ranges from 0.5 to 4.0 and varies according to user settings.
defaultDensitynumberYesNoDefault display size scale factor for the screen where the window is located. The value ranges from 0.5 to 4.0 and varies with the screen.
customDensitynumberYesNoCustom display size scale factor of the window. The value ranges from 0.5 to 4.0. If this parameter is left unspecified, the system's display size scale factor is used.

WindowLayoutInfo15+

Describes the information about the window layout.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.Window.SessionManager

NameTypeMandatoryDescription
windowRect15+RectYesWindow rectangle, that is, the position and size of the window on the display.

KeyboardInfo18+

Describes the information about the soft keyboard window.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.Window.SessionManager

NameTypeMandatoryDescription
beginRectRectYesPosition and size of the soft keyboard before the animation starts.
endRectRectYesPosition and size of the soft keyboard before the animation ends.
animated20+booleanNoWhether there is a show/hide animation. The value true means that there is a show/hide animation, and false means the opposite.
config20+WindowAnimationConfigNoAnimation configuration.

ShowWindowOptions20+

Describes the parameters for displaying a child window or system window.

System capability: SystemCapability.Window.SessionManager

Atomic service API: This API can be used in atomic services since API version 20.

NameTypeMandatoryDescription
focusOnShowbooleanNoWhether the window automatically gains focus when showWindow() is called. The default is true. This parameter does not take effect for the main window, modal window, and dialog boxes.

WindowAnimationConfig20+

Describes the configuration for window animation.

Atomic service API: This API can be used in atomic services since API version 20.

System capability: SystemCapability.Window.SessionManager

NameTypeMandatoryDescription
curveWindowAnimationCurveYesType of animation curve.
durationnumberNoDuration for playing the animation, in milliseconds (ms).
The default value is 0, and the maximum value is 3000.
Whether it is required depends on the animation curve type.
paramWindowAnimationCurveParamNoParameters for the animation curve. Whether it is required depends on the animation curve type.

WindowInfo18+

Describes the window information.

System capability: SystemCapability.Window.SessionManager

NameTypeRead-OnlyOptionalDescription
rectRectYesNoWindow size.
bundleNamestringYesNoBundle name of the application.
abilityNamestringYesNoAbility name.
windowIdnumberYesNoWindow ID.
windowStatusTypeWindowStatusTypeYesNoWindow mode.
isFocusedbooleanYesYesWhether the window gains focus. The value true means that the window gains focus, and false means the opposite.

TransitionAnimation20+

Describes the window transition animation.

Atomic service API: This API can be used in atomic services since API version 20.

System capability: SystemCapability.Window.SessionManager

NameTypeMandatoryDescription
configWindowAnimationConfigYesTransition animation configuration.
opacitynumberNoOpacity of the window during the transition animation. If this parameter is set to 0, the window is completely transparent. When the animation type is WindowTransitionType.DESTROY, this represents the opacity at the end of the animation. The value ranges from 0 to 1. The value is reset to 1 when the animation ends.

Callback15+

(data: T)15+

(data: T): V;

Describes a generic callback function.

You can set data to customize the parameter type of the information returned by the callback.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.Window.SessionManager

Parameters

NameTypeMandatoryDescription
dataTYesParameter of type T that needs to be passed when the callback function is called.

Return value

TypeDescription
VValue of type V.

RotationChangeInfo19+

Describes the window information obtained during window rotation changes.

Atomic service API: This API can be used in atomic services since API version 19.

System capability: SystemCapability.Window.SessionManager

NameTypeRead-OnlyOptionalDescription
typeRotationChangeTypeNoNoType of window rotation event.
orientationnumberNoNoDisplay orientation of the window.
- 0: portrait.
- 1: reverse landscape.
- 2: reverse portrait.
- 3: landscape.
Note that the orientation here is different from the orientation property of the display object.
displayIdnumberNoNoID of the screen where the window is located.
displayRectRectNoNoSize of the rectangle after the screen where the window is located is rotated.

RotationChangeResult19+

Describes the information returned by the application during window rotation changes.

The system uses the information to adjust the size of the current window rectangle. If the returned information is about the rotation change of the main window, the system does not change the size of the main window.

There are limitations on the size of application windows and system windows. For details about specific restrictions and rules, see resize.

Atomic service API: This API can be used in atomic services since API version 19.

System capability: SystemCapability.Window.SessionManager

NameTypeRead-OnlyOptionalDescription
rectTypeRectTypeNoNoType of window rectangle coordinate system.
windowRectRectNoNoInformation about the window's rectangle relative to the screen or parent window coordinate system.

RotationChangeCallback19+

(info: T)19+

(info: T): U;

Describes a generic callback function for rotation event notifications.

In this callback function, the parameter type is RotationChangeInfo, and the return value type is RotationChangeResult|void.

Atomic service API: This API can be used in atomic services since API version 19.

System capability: SystemCapability.Window.SessionManager

Parameters

NameTypeMandatoryDescription
infoTYesParameter of type RotationChangeInfo passed by the system when the callback function is called.

Return value

TypeDescription
UValue of type RotationChangeResult|void.

SubWindowOptions11+

Describes the parameters used for creating a child window.

System capability: SystemCapability.Window.SessionManager

NameTypeRead-OnlyOptionalDescription
title11+stringNoNoTitle of the child window. The title display area should not go past the left side of the three-button area of the system. Any part that goes beyond will show as an ellipsis.
Atomic service API: This API can be used in atomic services since API version 12.
decorEnabled11+booleanNoNoWhether decorations are displayed in the child window. The value true means that decorations are displayed, and false means the opposite.
Atomic service API: This API can be used in atomic services since API version 12.
isModal12+booleanNoYesWhether the modal property is enabled for the child window. The value** true** means that the modal property is enabled for the child window, and false means to disable it. The default value is false.
Atomic service API: This API can be used in atomic services since API version 12.
modalityType14+ModalityTypeNoYesModality type of the child window. This parameter takes effect only when the modal property is enabled for the child window. WINDOW_MODALITY means window-modal, and APPLICATION_MODALITY means application-modal. The default value is WINDOW_MODALITY.
Atomic service API: This API can be used in atomic services since API version 14.
windowRect18+RectNoYesRectangle of the child window, and the size of the child window is limited. For details, see resize(). If this parameter is not specified, the window is displayed in full screen by default.
Atomic service API: This API can be used in atomic services since API version 18.
zLevel18+numberNoYesZ-level of the child window. This parameter is valid only when the modal property is not enabled for the child window, that is, isModal is not set. The value is an integer in the range [-10000, 10000]. Floating-point numbers will be rounded down. The default value is 0.
Atomic service API: This API can be used in atomic services since API version 18.
maximizeSupported19+booleanNoYesWhether the child window supports maximization. This API can be used only on 2-in-1 devices. The value true means that the child window supports maximization, and false means the opposite. The default value is false.
Atomic service API: This API can be used in atomic services since API version 19.
outlineEnabled20+booleanNoYesWhether the child window displays an outline. This API can be used only on 2-in-1 devices. The value true means that the child window displays an outline, and false means the opposite. The default value is false.
Atomic service API: This API can be used in atomic services since API version 20.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArkUI

harmony 鸿蒙ARKUI_TextPickerCascadeRangeContent

harmony 鸿蒙ARKUI_TextPickerRangeContent

harmony 鸿蒙ArkUI_AnimateCompleteCallback

harmony 鸿蒙ArkUI_AttributeItem

harmony 鸿蒙ArkUI_ColorStop

harmony 鸿蒙ArkUI_ContextCallback

harmony 鸿蒙ArkUI_EventModule

harmony 鸿蒙ArkUI_ExpectedFrameRateRange

harmony 鸿蒙ArkUI_IntOffset

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/ANDyvv