public class Window extends Object
This class provides methods of modifying attributes of windows based on LayoutConfig.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
Window.IAccessibilityEventListener |
An implementation class for Populate Accessibility Event Listener.
|
| 构造器 | 说明 |
|---|---|
Window() |
A constructor used to create a
Window instance. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addFlags(int flags) |
Add window flags.
|
void |
addWindowFlags(int flags) |
Add the characteristic flags of a window in ohos.
|
void |
clearFlags(int flags) |
Clears flags from a window.
|
void |
clearWindowFlags(int flags) |
Clear the flags from a window.
|
float |
getAltitude() |
Obtains the altitude of a window in the direction perpendicular to the phone screen.
|
Rect |
getBoundRect() |
Obtain the bounds of a moving window.
|
Optional<Component> |
getCurrentComponentFocus() |
Obtain the
Component object that has gained focus in this window. |
Optional<WindowManager.LayoutConfig> |
getLayoutConfig() |
Obtain the
LayoutConfig object of the Window instance to read or modify. |
LayoutScatter |
getLayoutScatter() |
Obtain the layout scatter of this window.
|
int |
getStatusBarVisibility() |
Obtain whether the status bar is visible.
|
int |
getSystemBarStyle() |
Obtain the visibility type of the navigation bar or status bar.
|
boolean |
isActive() |
Check whether this window is active.
|
boolean |
isMovable() |
Check whether a window is movable.
|
boolean |
isWCGMode() |
Check whether this window is in wide color gamut (WCG) mode.
|
int |
replicateFrom(WindowManager.LayoutConfig param) |
Set a layout attribute for this window.
|
void |
setAccessibilityEventListener(Window.IAccessibilityEventListener listener) |
Set a listener for accessibility events.
|
void |
setAltitude(float altitude) |
Sets the altitude of a window in the direction perpendicular to the phone screen.
|
void |
setBackground(String elementPath) |
Set the background for a window.
|
void |
setBackgroundColor(RgbColor rgbColor) |
Set the background color of a window.
|
void |
setBoundRect(Rect boundRect) |
Set the bounds of a moving window.
|
void |
setInputPanelDisplayType(int type) |
Set the display type for the soft input panel.
|
void |
setLayoutAlignment(int alignment) |
Set the text alignment for a window.
|
void |
setLayoutConfig(WindowManager.LayoutConfig param) |
Set the
LayoutConfig of the Window instance. |
void |
setLayoutFlags(int flags,
int mask) |
Set flags for a window.
|
void |
setLayoutInDisplaySideMode(int mode) |
Set the display mode for the sidebar of this Window.
|
void |
setLayoutInNotchMode(WindowManager.NotchMode mode) |
Sets the display mode for this window in the notch.
|
void |
setMovable(boolean isMovable) |
Set whether a window is movable.
|
void |
setNavigationBarColor(int color) |
Set the color of a navigation bar.
|
void |
setOnApplyComponentPaddingListener(IApplyComponentPaddingListener listener) |
Set a listener to monitor
ComponentPadding changes. |
void |
setPadding(int left,
int top,
int right,
int bottom) |
Set the inner padding of a window in the sequence of left, top, right, and bottom.
|
void |
setPixelFormat(int format) |
Set the pixel format for this window.
|
void |
setShadowStyle(Component.ShadowSize size,
Component.ShadowMode mode,
Component.ShadowDevice device) |
Sets the shadow style of a window.
|
void |
setStatusBarColor(int color) |
Set the color of the status bar.
|
void |
setStatusBarVisibility(int visibility) |
Set whether the status bar is visible.
|
void |
setSystemBarStyle(int visibility) |
Sets the visibility of the navigation bar or status bar.
|
void |
setTransparent(boolean isEnable) |
Set whether to enable transparency.
|
void |
setWindowFlags(int flags,
int mask) |
Set window flags.
|
void |
setWindowLayout(int width,
int height) |
Set the size of a window.
|
public Window()
Window instance.
This method can also be used for tests.
public boolean isMovable()
True if the window is movable; returns false otherwise.public void setMovable(boolean isMovable)
isMovable - Indicate whether the window is movable.
True indicates movable; false indicates otherwise.public Rect getBoundRect()
public void setBoundRect(Rect boundRect)
boundRect - Indicates the rectangular bounds of the window.public Optional<WindowManager.LayoutConfig> getLayoutConfig()
LayoutConfig object of the Window instance to read or modify.WindowManager.LayoutConfig attributes of the Window instance.NullPointerException - Throws this exception if mAgpWindow is null.public void setLayoutConfig(WindowManager.LayoutConfig param)
LayoutConfig of the Window instance.param - Indicates the parameters to pass to this method.
You can obtain the LayoutConfig parameters
from the getLayoutConfig() method.NullPointerException - Throws this exception if input para is null.public void setLayoutAlignment(int alignment)
You can obtain the supported attributes from TextAlignment.
alignment - Indicates the alignment attribute to set for the window.public void addFlags(int flags)
WindowManager.LayoutConfig.flags - Indicates the flags to set add.public void clearFlags(int flags)
flags - Indicates the flags to be cleared from the window.public void setLayoutFlags(int flags,
int mask)
Different from the addFlags(int flags) method, this method
clears the existing flags using the attrs.flag &~ mask calculation and then sets new flags.
flags - Indicates the new flags specified by
WindowManager.LayoutConfig.mask - Indicates the mask of the window.NullPointerException - Throws this exception if mAgpWindow is null.public void setWindowLayout(int width,
int height)
width - Indicates the width of the window.height - Indicates the height of the window.public void setNavigationBarColor(int color)
color - Indicates the color of the navigation bar.NullPointerException - Throws this exception if mAgpWindow is null.public void setStatusBarColor(int color)
color - Indicates the color of the status bar.NullPointerException - Throws this exception if mAgpWindow is null.public void setPadding(int left,
int top,
int right,
int bottom)
left - Indicates the left padding.top - Indicates the top padding.right - Indicates the right padding.bottom - Indicates the bottom padding.NullPointerException - Throws this exception if mAgpWindow is null.public void setStatusBarVisibility(int visibility)
Component.INVISIBLE indicates the status bar is invisible.visibility - Indicates whether the status bar is visible.
Component.VISIBLE indicates visible; Component.INVISIBLE indicates invisible.NullPointerException - Throws this exception if mAgpWindow is null.public int getStatusBarVisibility()
Component.INVISIBLE indicates the status bar is invisible.Component.VISIBLE if the status bar is visible;
Return Component.INVISIBLE if the status bar is invisible.NullPointerException - Throws this exception if mAgpWindow is null.public void setSystemBarStyle(int visibility)
visibility - Indicates the visibility type. The value can be
WindowManager.LayoutConfig#SYSTEM_BAR_HIDE_NAVIGATION_ONCE,
WindowManager.LayoutConfig#SYSTEM_BAR_HIDE_STATUS_ONCE,
WindowManager.LayoutConfig#SYSTEM_BAR_HIDE_NAVIGATION_AUTO,
WindowManager.LayoutConfig#SYSTEM_BAR_HIDE_STATUS_AUTO,
WindowManager.LayoutConfig#SYSTEM_BAR_BRIGHT_STATUS,
or WindowManager.LayoutConfig#SYSTEM_BAR_BRIGHT_NAVIGATION.NullPointerException - Throws this exception if mAgpWindow is null.public int getSystemBarStyle()
NullPointerException - Throws this exception if mAgpWindow is null.public Optional<Component> getCurrentComponentFocus()
Component object that has gained focus in this window.Component object that has gained focus in this window.NullPointerException - Throws this exception if mAgpWindow is null.public void setBackgroundColor(RgbColor rgbColor)
rgbColor - Indicates the value of the color for the window.NullPointerException - Throws this exception if mAgpWindow is null.public void setBackground(String elementPath)
elementPath - Indicates the path of background resources for the window.NullPointerException - Throws this exception if mAgpWindow is null.public void addWindowFlags(int flags)
WindowManager.LayoutConfig.flags - Indicates the value of the flags to set for the window.public void clearWindowFlags(int flags)
flags - Indicates the window flags to be cleared.public void setWindowFlags(int flags,
int mask)
flags - Indicates the window flags to set.mask - Indicates the mask to set.NullPointerException - Throws this exception if mAgpWindow is null.public void setTransparent(boolean isEnable)
isEnable - Specifies whether transparency is enabled.
True indicates that transparency is enabled, and False indicates disabled.NullPointerException - Throws this exception if mAgpWindow is null.public void setOnApplyComponentPaddingListener(IApplyComponentPaddingListener listener)
ComponentPadding changes.listener - IApplyComponentPaddingListenerNullPointerException - Throw this exception if input para is null.public LayoutScatter getLayoutScatter()
NullPointerException - Throws this exception if mAgpWindow is null.LayoutScatterpublic boolean isActive()
true if this window is active; return false otherwise.NullPointerException - Throws this exception if mAgpWindow is null.public boolean isWCGMode()
true if this window is in WCG mode; return false otherwise.NullPointerException - Throws this exception if mAgpWindow is null.public void setPixelFormat(int format)
format - Indicate the pixel format to set.NullPointerException - Throws this exception if mAgpWindow is null.Surface.PixelFormat#PIXEL_FORMAT_YCBCR_422_I,
Surface.PixelFormat#PIXEL_FORMAT_YCRCB_420_SP,
Surface.PixelFormat#PIXEL_FORMAT_YV12public int replicateFrom(WindowManager.LayoutConfig param)
param - Indicate the layout attribute to set.WindowManager.LayoutConfig#ALTER_LAYOUT.NullPointerException - Throws this exception if mAgpWindow is null.public void setLayoutInDisplaySideMode(int mode)
mode - Indicate the display mode to set. The value can be
WindowManager.LayoutConfig#LAYOUT_IN_DISPLAY_SIDE_MODE_DEFAULT,
WindowManager.LayoutConfig#LAYOUT_IN_DISPLAY_SIDE_MODE_ALWAYS,
or WindowManager.LayoutConfig#LAYOUT_IN_DISPLAY_SIDE_MODE_NEVER.NullPointerException - Throws this exception if mAgpWindow is null.public void setLayoutInNotchMode(WindowManager.NotchMode mode)
mode - Indicates the display mode for this window in the notch.
For details, see WindowManager.NotchMode.public void setAccessibilityEventListener(Window.IAccessibilityEventListener listener)
listener - Indicate the listener to set.public void setInputPanelDisplayType(int type)
type - Indicates the display type to set, which can be
WindowManager.LayoutConfig#INPUT_ADJUST_RESIZE,
WindowManager.LayoutConfig#INPUT_ADJUST_PAN,
or WindowManager.LayoutConfig#INPUT_ADJUST_NOTHING.NullPointerException - Throws this exception if mAgpWindow is null.public float getAltitude()
setAltitude(float)public void setAltitude(float altitude)
Indicates - the altitude of the window in the direction perpendicular to the phone screen.getAltitude()public void setShadowStyle(Component.ShadowSize size, Component.ShadowMode mode, Component.ShadowDevice device)
The shadow style is generated based on the input size, mode, and device.
size - Indicates the shadow size, which is defined in Component.ShadowSize.mode - Indicates the shadow mode, which is defined in Component.ShadowMode.device - Indicates the device type, which is defined in Component.ShadowDevice.