鸿蒙OS开发文档 第27页

鸿蒙OS ComponentTreeObserver

ComponentTreeObserver java.lang.Object |—ohos.agp.components.ComponentTreeObserver public final class ComponentTreeObserver extends Object 定义组件层次结构的侦听器。 您可以注册侦听器以监视组件层次结构中的全局更改。 嵌套类摘要 修饰符和类型 类 描述 static interface ComponentTreeObserver.GlobalFocusUpdatedListener 当组件树中的焦点状态发生变化时调用的回调。 static interface ComponentTreeObserver.GlobalLayoutListener 已弃用。 此更改从 API 版本 6 开始生效。替换为 Component.LayoutRefreshedListener static interface ComponentTreeObserver.ScrollChangedListener 滚动组件层次结构中的任何元素时调用的回调。 static interface ComponentTreeObserver.WindowBoundListener 当组件层次结构绑定到其窗口或从其窗口解除绑定时调用的回调。 static interface ComponentTreeObserver.WindowFocusUpdatedListener 当组件层次结构中窗口焦点状态发生变化时调用的回调。 方法总结 修饰符和类型 方法 描述 void addGlobalFocusUpdatedListener(ComponentTreeObserver.GlobalFocusUpdatedListener listener) 为 globalFocusChanged() 注册一个监听器。 void addScrolledListener(ComponentTreeObserver.ScrollChangedListener listener) 为 scrollChanged() 注册一个监听器。 void addTreeLayoutChangedListener(ComponentTreeObserver.GlobalLayoutListener listener) 已弃用。 此更改从 API 版本 6 开始生效。替换为 setLayoutRefreshedListener(Component.LayoutRefreshedListener) void addWindowBoundListener(ComponentTreeObserver.WindowBoundListener listener) 为 windowBound() 注册一个监听器。 void addWindowFocusUpdatedListener(ComponentTreeObserver.WindowFocusUpdatedListener listener) 为 windowFocusUpdated() 注册一个监听器。 void removeGlobalFocusUpdatedListener(ComponentTreeObserver.GlobalFocusUpdatedListener listener) 删除为 globalFocusChanged() 注册的侦听器。 void removeScrolledListener(ComponentTreeObserver.ScrollChangedListener listener) 删除为 scrollChanged() 注册的侦听器。 void removeTreeLayoutChangedListener(ComponentTreeObserver.GlobalLayoutListener listener) 已弃用。 此更改从 API 版本 6 开始生效。由 setLayoutRefreshedListener(Component.LayoutRefreshedListener) 替换为 null 侦听器值。 void removeWindowBoundListener(ComponentTreeObserver.WindowBoundListener listener) 删除为 windowAttached() 注册的侦听器。 void removeWindowFocusUpdatedListener(ComponentTreeObserver.WindowFocusUpdatedListener listener) 删除为 windowFocusUpdated() 注册的侦听器。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 方法详情 addWindowFocusUpdatedListener public void addWindowFocusUpdatedListener(ComponentTreeObserver.WindowFocusUpdatedListener listener) 为 windowFocusUpdated() 注册一个监听器。 参数: 参数名称 参数描述 listener 指示要注册的侦听器。 removeWindowFocusUpdatedListener public void removeWindowFocusUpdatedListener(ComponentTreeObserver.WindowFocusUpdatedListener listener) 删除为 windowFocusUpdated() 注册的侦听器。 参数: 参数名称 参数描述 listener 指示要删除的侦听器。 addWindowBoundListener public void addWindowBoundListener(ComponentTreeObserver.WindowBoundListener listener) 为 windowBound() 注册一个监听器。 参数: 参数名称 参数描述 listener 指示要注册的侦听器。 removeWindowBoundListener public void removeWindowBoundListener(ComponentTreeObserver.WindowBoundListener listener) 删除为 windowAttached() 注册的侦听器。 参数: 参数名称 参数描述 listener...

鸿蒙OS ComponentTransition

ComponentTransition java.lang.Object |—ohos.agp.components.ComponentTransition public class ComponentTransition extends Object 为 ComponentContainer 对象的布局更改提供动画。 要在布局容器上执行布局转换,请创建一个 ComponentTransition 对象,然后使用 ComponentContainer#setComponentTransition 设置一个 ComponentContainer 对象。 字段摘要 修饰符和类型 字段 描述 static int CHANGING 指示在由布局修改更改的组件上运行的动画,而不是通过在布局容器中添加或删除组件。 static int OTHERS_GONE 指示在组件上运行的动画,因为它们的关联组件之一从 ComponentContainer 中消失而发生更改。 static int OTHERS_SHOW 指示在组件上运行的动画,因为它们的关联组件之一出现在 ComponentContainer 中而发生更改。 static int SELF_GONE 表示当组件从 ComponentContainer 中消失时在组件上运行的动画。 static int SELF_SHOW 表示当组件出现在 ComponentContainer 中时在组件上运行的动画。 构造函数摘要 构造函数 描述 ComponentTransition() 用于创建 ComponentTransition 实例的默认构造函数。 方法总结 修饰符和类型 方法 描述 void addTransitionType(int type) 为 ComponentTransition 对象启用过渡类型。 AnimatorProperty getAnimatorProperty(int type) 获取指定转场类型的组件属性动画器。 boolean hasTransitionType(int type) 检查是否为 ComponentTransition 对象启用了指定的过渡类型。 void release() 释放一个 ComponentTransition 对象。 void removeTransitionType(int type) 从 ComponentTransition 对象中移除过渡类型。 void setAnimatorProperty(int type, AnimatorProperty animator) 设置指定转换类型的可自定义组件属性动画器。 void setTransitionTypeDuration(int type, int duration) 设置指定过渡类型动画的持续时间。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 字段详细信息 CHANGING public static final int CHANGING 指示在由布局修改更改的组件上运行的动画,而不是通过在布局容器中添加或删除组件。 默认情况下,此转换类型被禁用。 您可以调用 addTransitionType(int) 来启用它。 OTHERS_GONE public static final int OTHERS_GONE 指示在组件上运行的动画,因为它们的关联组件之一从 ComponentContainer 中消失而发生更改。 OTHERS_SHOW public static final int OTHERS_SHOW 指示在组件上运行的动画,因为它们的关联组件之一出现在 ComponentContainer 中而发生更改。 SELF_GONE public static final int SELF_GONE 表示当组件从 ComponentContainer 中消失时在组件上运行的动画。 SELF_SHOW public static final int SELF_SHOW 表示当组件出现在 ComponentContainer 中时在组件上运行的动画。 构造函数详细信息...

鸿蒙OS ComponentState

ComponentState java.lang.Object |—ohos.agp.components.ComponentState public class ComponentState extends Object 定义组件状态。 组件状态可以是 COMPONENT_STATE_FOCUSED、COMPONENT_STATE_SELECTED、COMPONENT_STATE_WINDOW_FOCUSED、COMPONENT_STATE_DISABLED、COMPONENT_STATE_CHECKED、COMPONENT_STATE_DRAG_ENTERED、COMPONENT_STATE_DRAG_RESPONDED、COMPONENT_STATE_PRESSED 或 COMPONENT_STATE_HOVERED。 字段摘要 修饰符和类型 字段 描述 static int COMPONENT_STATE_CHECKED 表示选中状态。 static int COMPONENT_STATE_DISABLED 表示禁用状态。 static int COMPONENT_STATE_DRAG_ENTERED 指示组件在拖动过程中被另一个组件悬停的状态。 static int COMPONENT_STATE_DRAG_RESPONDED 表示可以响应拖动事件的状态。 static int COMPONENT_STATE_EMPTY 表示为空的状态。 static int COMPONENT_STATE_FOCUSED 表示聚焦状态。 static int COMPONENT_STATE_HOVERED 表示悬停状态。 static int COMPONENT_STATE_PRESSED 表示按下状态。 static int COMPONENT_STATE_SELECTED 表示选中状态。 static int COMPONENT_STATE_WINDOW_FOCUSED 表示组件的窗口获得焦点的状态。 构造函数摘要 构造函数 描述 ComponentState() 方法总结 修饰符和类型 方法 描述 static boolean isStateMatched(int stateFlag, int stateMask) 检查状态是否与给定状态匹配。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 字段详细信息 COMPONENT_STATE_CHECKED public static final int COMPONENT_STATE_CHECKED 表示选中状态。 COMPONENT_STATE_DISABLED public static final int COMPONENT_STATE_DISABLED 表示禁用状态。 COMPONENT_STATE_DRAG_ENTERED public static final int COMPONENT_STATE_DRAG_ENTERED 指示组件在拖动过程中被另一个组件悬停的状态。 COMPONENT_STATE_DRAG_RESPONDED public static final int COMPONENT_STATE_DRAG_RESPONDED 表示可以响应拖动事件的状态。 COMPONENT_STATE_EMPTY public static final int COMPONENT_STATE_EMPTY 表示为空的状态。 COMPONENT_STATE_FOCUSED public static final int COMPONENT_STATE_FOCUSED 表示聚焦状态。 COMPONENT_STATE_HOVERED public static final int COMPONENT_STATE_HOVERED 表示悬停状态。 COMPONENT_STATE_PRESSED public static final int COMPONENT_STATE_PRESSED 表示按下状态。 COMPONENT_STATE_SELECTED...

鸿蒙OS ComponentSaveState

ComponentSaveState java.lang.Object |—ohos.agp.components.AbsComponentSaveState |—|—ohos.agp.components.ComponentSaveState public class ComponentSaveState extends AbsComponentSaveState 用于保存和恢复组件状态的超类。 如果一个组件需要保存一个特定的状态,它必须继承这个类。 嵌套类摘要 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 修饰符和类型 字段 描述 static Sequenceable.ProducerComponentSaveState PRODUCER 基于 Parcel 对象创建一个 ComponentSaveState 实例。 从类 ohos.agp.components.AbsComponentSaveState 继承的字段 EMPTY_STATE 构造函数摘要 构造函数 描述 ComponentSaveState(Parcel in) 用于创建基于 Parcel 对象的 ComponentSaveState 实例的构造函数。 ComponentSaveState(Parcel in, ClassLoader classLoader) 用于创建基于 Parcel 和 ClassLoader 对象的 ComponentSaveState 实例的构造函数。 ComponentSaveState(Sequenceable superState) 用于创建基于 superState 的 ComponentSaveState 实例的构造函数。 方法总结 修饰符和类型 方法 描述 boolean marshalling(Parcel parcel) 将此 Sequenceable 对象编组为 Parcel。 从类 ohos.agp.components.AbsComponentSaveState 继承的方法 getSuperState, unmarshalling 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 从接口 ohos.utils.Sequenceable 继承的方法 hasFileDescriptor 字段详细信息 PRODUCER public static final Sequenceable.ProducerComponentSaveState PRODUCER 基于 Parcel 对象创建一个 ComponentSaveState 实例。 构造函数详细信息 ComponentSaveState public ComponentSaveState(Sequenceable superState) 用于创建基于 superState 的 ComponentSaveState 实例的构造函数。 此方法由派生类调用。 参数: 参数名称 参数描述 superState 指示此组件的超类的状态。 ComponentSaveState public ComponentSaveState(Parcel in) 用于创建基于 Parcel 对象的 ComponentSaveState 实例的构造函数。 参数: 参数名称 参数描述 in 指示组件从中读取数据的 Parcel 对象。 ComponentSaveState public ComponentSaveState(Parcel in, ClassLoader classLoader) 用于创建基于 Parcel 和 ClassLoader 对象的 ComponentSaveState 实例的构造函数。 参数: 参数名称 参数描述 in 指示组件从中读取数据的 Parcel 对象。 classLoader 指示要使用的 ClassLoader 对象。 方法详情 marshalling public...

鸿蒙OS ComponentProvider.Action

ComponentProvider.Action java.lang.Object |—ohos.agp.components.ComponentProvider.Action public abstract static class ComponentProvider.Action extends Object implements Sequenceable 描述可以对远程组件执行的操作。 远程组件是可以在另一个应用程序中显示和更新的组件层次结构。 嵌套类摘要 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 修饰符和类型 字段 描述 static int MERGE_REPLACE 允许合并和替换。 int viewId 表示组件ID。 构造函数摘要 构造函数 描述 Action() 方法总结 修饰符和类型 方法 描述 abstract void apply(ComponentContainer root) 应用更新组件内容的动作。 String getActionKey() 获取操作键。 abstract int getActionTag() 获取动作类型。 int mergeOperation() 返回合并行为。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 从接口 ohos.utils.Sequenceable 继承的方法 hasFileDescriptor, marshalling, unmarshalling 字段详细信息 MERGE_REPLACE public static final int MERGE_REPLACE 允许合并和替换。 当多个 ComponentProvider.Action 应用于同一个组件的同一个属性时,这些动作可以被合并。 viewId public int viewId 表示组件ID。 构造函数详细信息 Action public Action() 方法详情 apply public abstract void apply(ComponentContainer root) throws ComponentProvider.ComponentProviderException 应用更新组件内容的动作。 参数: 参数名称 参数描述 root 表示 ComponentProvider 定义的所有组件的根节点。 Throws: Throw名称 Throw描述 ComponentProvider.ComponentProviderException 如果系统无法处理错误,则抛出此异常。 mergeOperation public int mergeOperation() 返回合并行为。 默认值为 MERGE_REPLACE。 返回: 默认情况下返回 MERGE_REPLACE。 getActionTag public abstract int getActionTag() 获取 Action 类型。 返回的操作类型取决于 ComponentProvider.Action。 返回: 返回 Action...

鸿蒙OS ComponentProvider

ComponentProvider java.lang.Object |—ohos.agp.components.ComponentProvider public class ComponentProvider extends Object implements Sequenceable 为跨进程显示提供远程组件。 该类提供了一组用于修改远程组件内容的基本操作。 它通常用于开发显示在通知栏中的通知以及桌面或主屏幕上的小部件。 嵌套类摘要 修饰符和类型 类 描述 static class ComponentProvider.Action 描述可以对远程组件执行的操作。 static class ComponentProvider.ComponentProviderException 对远程组件操作期间发生的错误引发异常。 从接口 ohos.utils.Sequenceable 继承的嵌套类/接口 Sequenceable.ProducerT 字段摘要 修饰符和类型 字段 描述 static int APPLY_TYPE_ACTIONS_ONLY 在 ComponentProvider 对象更新后应用所有操作。 static int APPLY_TYPE_LAYOUT_AND_ACTIONS 在创建 ComponentProvider 对象后扩展布局并应用所有操作。 构造函数摘要 构造函数 描述 ComponentProvider() 用于创建 ComponentProvider 的默认构造函数。 ComponentProvider(int layoutId, Context context) 用于根据应用程序的布局 ID 和上下文创建 ComponentProvider 实例的构造函数。 方法总结 修饰符和类型 方法 描述 void applyAction(ComponentContainer root) 应用当前进程中的所有操作。 CollectionComponentProvider.Action getActions() 获取所有动作。 ComponentContainer getAllComponents() 获取 ComponentContainer 中的所有组件。 int getApplyType() 获取操作类型。 String getDefaultBundleName() 获取默认捆绑包名称。 int getLayoutId() 获取布局ID。 void inflateLayout(Context context) 根据布局定义扩展布局。 boolean isValidComponentId(int componentId) 根据提供的组件 ID 检查组件是否有效。 boolean marshalling(Parcel out) 编组 ComponentProvider 对象,然后将其写入 Parcelobject。 void mergeAction(ComponentProvider.Action action) 将 ComponentProvider.Action 对象合并到一个 ComponentProvider 对象中。 void mergeActions(CollectionComponentProvider.Action actions) 将所有 Action 对象合并并存储到一个 ComponentProvider 对象中。 void resetActions() 清除当前 ComponentProvider 对象中的所有操作。 ComponentProvider.Action setAccessibilityDescription(int componentId, String description) 设置指定组件的可访问性模式的描述.. boolean setApplyType(int applyType) 设置操作类型。 ComponentProvider.Action setBackgroundPixelMap(int componentId, PixelMap pixelMap) 设置组件的背景图像。 ComponentProvider.Action setBoolean(int componentId, String methodName, boolean value) 调用组件的指定接口。 ComponentProvider.Action setClipToContourEnabled(int componentId, boolean enable) 设置组件的轮廓是否可以用于内容裁剪。 ComponentProvider.Action setComponentContainerLayoutConfig(int componentId, ComponentContainer.LayoutConfig params) 设置组件的边距布局参数。 void setDefaultBundleName(String bundleName) 设置获取资源的默认捆绑包名称。 ComponentProvider.Action setDouble(int componentId, String methodName, double value) 调用组件的指定接口。 ComponentProvider.Action setFloat(int componentId, String methodName, float value) 调用组件的指定接口。 ComponentProvider.Action setImageContent(int componentId, int resId) 设置要在指定图像组件上显示的内容。 ComponentProvider.Action setImagePixelMap(int componentId, PixelMap pixelMap) 设置组件的图像内容。 ComponentProvider.Action setInt(int componentId, String methodName, int value) 调用组件的指定接口。...

鸿蒙OS ComponentHolder

ComponentHolder java.lang.Object |—ohos.agp.components.ComponentHolder public class ComponentHolder extends Object 表示 XML 文件中的组件持有者(布局)。 方法总结 修饰符和类型 方法 描述 void hide() 在父布局中隐藏此 ComponentHolder 布局。 Component show() 在父布局中显示此 ComponentHolder 布局。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 方法详情 show public Component show() 在父布局中显示此 ComponentHolder 布局。 返回: 返回此 ComponentHolder 布局中的组件。 hide public void hide() 在父布局中隐藏此 ComponentHolder 布局。

鸿蒙OS ComponentContainer.LayoutConfig

ComponentContainer.LayoutConfig java.lang.Object |—ohos.agp.components.ComponentContainer.LayoutConfig public static class ComponentContainer.LayoutConfig extends Object implements Cloneable 提供布局参数,例如宽度和高度以及边距。 可以提供每个子组件的边距布局信息。 字段摘要 修饰符和类型 字段 描述 int height 组件高度。 static int MATCH_CONTENT MATCH_CONTENT 意味着组件将足够大以包含其内容并使用自己的填充。 static int MATCH_PARENT MATCH_PARENT 表示每个子组件将与其父组件大小相同,但需要扣除父填充大小(如果有)。 int width 组件宽度。 构造函数摘要 构造函数 描述 LayoutConfig() 默认构造函数用于创建 LayoutConfig 实例,其宽度和高度默认设置为 MATCH_CONTENT。 LayoutConfig(int width, int height) 用于通过指定宽度和高度来创建 LayoutConfig 实例的构造函数。 LayoutConfig(ComponentContainer.LayoutConfig config) 用于从现有 LayoutConfig 实例创建 LayoutConfig 实例的构造函数。 LayoutConfig(Context context, AttrSet attrSet) 从 AttrSet 获取属性以实例化 LayoutConfig。 方法总结 修饰符和类型 方法 描述 Object clone() 创建并返回此对象的副本。 int getHorizontalEndMargin() 获取结束边距。 int getHorizontalStartMargin() 获取起始边距。 Component.LayoutDirection getLayoutDirection() 返回布局方向:LayoutDirection#LTR 或 LayoutDirection#RTL int getMarginBottom() 获取下边距。 int getMarginLeft() 获取左边距。 int getMarginRight() 获得右边距。 int[] getMargins() 获取组件的左、上、右、下边距。 int[] getMarginsLeftAndRight() 获取组件的水平(左右)边距。 int[] getMarginsTopAndBottom() 获取组件的垂直(顶部和底部)边距。 int getMarginTop() 获得上边距。 protected boolean isMarginsRelative() 检查当前边距是否是相对的。 void setMarginBottom(int bottom) 设置组件的下边距。 void setMarginLeft(int left) 设置组件的左边距。 void setMarginRight(int right) 设置组件的右边距。 void setMargins(int left, int top, int right, int bottom) 以整数设置边距。 void setMarginsLeftAndRight(int left, int right) 设置组件的水平(左右)边距。 void setMarginsRelative(int start, int top, int end, int bottom) 以整数设置相对边距。 void setMarginsTopAndBottom(int top, int bottom) 设置组件的垂直(顶部和底部)边距。 void setMarginTop(int top) 设置组件的上边距。 从类 java.lang.Object 继承的方法 equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 字段详细信息 MATCH_CONTENT public static final int MATCH_CONTENT MATCH_CONTENT 意味着组件将足够大以包含其内容并使用自己的填充。 MATCH_PARENT public static...

鸿蒙OS ComponentContainer

ComponentContainer java.lang.Object |—ohos.agp.components.Component |—|—ohos.agp.components.ComponentContainer public abstract class ComponentContainer extends Component implements ComponentParent 可以包含其他组件(称为子组件)的特殊组件。 此布局基类继承自 Component。 嵌套类摘要 修饰符和类型 类 描述 static interface ComponentContainer.ArrangeListener 提供自定义组件排列流程的接口。 static class ComponentContainer.LayoutConfig 提供布局参数,例如宽度和高度以及边距。 从类 ohos.agp.components.Component 继承的嵌套类/接口 Component.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEvent 字段摘要 修饰符和类型 字段 描述 static int FOCUS_CHILDREN_FIRST 指示此组件在其任何子项之前获得焦点。 static int FOCUS_CHILDREN_HIDE 指示此组件阻止其子级获得焦点,即使它们是可聚焦的。 static int FOCUS_PARENT_FIRST 指示仅当其子组件均未请求焦点时,此组件才获得焦点。 protected ComponentContainer.ArrangeListener mArrangeListener 在排列过程中自定义子组件的排列 从类 ohos.agp.components.Component 继承的字段 ACCESSIBILITY_ADAPTABLE, ACCESSIBILITY_DISABLE, ACCESSIBILITY_ENABLE, AXIS_X, AXIS_Y, CONTOUR_BACKGROUND, CONTOUR_BORDER, CONTOUR_PADDING_BORDER, DEFAULT_SCALE, DRAG_DOWN, DRAG_HORIZONTAL, DRAG_HORIZONTAL_VERTICAL, DRAG_LEFT, DRAG_RIGHT, DRAG_UP, DRAG_VERTICAL, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED, EVENT_TYPE_COMPONENT_ACCESSIBILITY_FOCUSED_CLEAR, EVENT_TYPE_COMPONENT_CLICKED, EVENT_TYPE_COMPONENT_FOCUSED, EVENT_TYPE_COMPONENT_LONG_CLICKED, EVENT_TYPE_COMPONENT_SCROLLED, EVENT_TYPE_COMPONENT_SELECTED, EVENT_TYPE_COMPONENT_TEXT_UPDATE, EVENT_TYPE_NOTICE, EVENT_TYPE_NOTIFICATION_STATE_UPDATE, EVENT_TYPE_TOAST_SHOW, EVENT_TYPE_WINDOW_STATE_UPDATE, FOCUS_ADAPTABLE, FOCUS_DISABLE, FOCUS_ENABLE, FOCUS_NEXT, FOCUS_PREVIOUS, FOCUS_SIDE_BOTTOM, FOCUS_SIDE_LEFT, FOCUS_SIDE_RIGHT, FOCUS_SIDE_TOP, HIDE, HORIZONTAL, ID_DEFAULT, INHERITED_MODE, INVISIBLE, mBackgroundElement, mCanvasForTaskOverContent, mCanvasForTaskUnderContent, mComponentParent, mContext, mDrawTaskOverContent, mDrawTaskUnderContent, mEstimateSizeListener, mForegroundElement, mForwardHoverListener, mHoverEventListener, mKeyEventListener, mMouseEventListener, mPosition, mRotationEventListener, mShadowElement, mUnconsumedKeyEventListener, OVAL_MODE, OVAL_SCROLL_BAR_MODE, POSITION_X_INDEX, POSITION_Y_INDEX, RECT_MODE, RECT_SCROLL_BAR_MODE, SCROLL_AUTO_STAGE, SCROLL_IDLE_STAGE, SCROLL_NORMAL_STAGE, UNSPECIFIED_SCROLL_BAR_MODE, VERTICAL, VISIBLE 构造函数摘要 构造函数 描述 ComponentContainer(Context context) 默认构造函数用于使用默认属性集和样式创建 ComponentContainer 实例。 ComponentContainer(Context context, AttrSet attrSet) 用于在 XML 文件解析后使用指定的属性集和默认样式创建 ComponentContainer 实例的构造函数。 ComponentContainer(Context context, AttrSet attrSet, String styleName) 一个构造函数,用于在解析 XML 文件后使用指定的属性集和指定的样式创建一个 ComponentContainer 实例。 方法总结 修饰符和类型 方法 描述 void addComponent(Component childComponent) 通过在内部调用 addComponent(ohos.agp.components.Component,int index) 将组件添加到队列的末尾。 void addComponent(Component childComponent, int index) 将组件添加到指定位置。 void addComponent(Component childComponent, int width, int height) 添加一个组件并设置其宽度和高度。 void addComponent(Component childComponent, int index, ComponentContainer.LayoutConfig layoutConfig) 添加组件并设置其布局参数和位置。 void addComponent(Component childComponent, ComponentContainer.LayoutConfig layoutConfig) 添加一个组件并设置其布局参数。 ComponentContainer.LayoutConfig createLayoutConfig(Context context, AttrSet attrSet) 使用子组件的属性集创建布局参数。 protected void dispatchRestoreState(PlainArraySequenceable stateContainer) 分发状态恢复过程来恢复该组件及其子组件的状态。 protected void dispatchSaveState(PlainArraySequenceable stateContainer) 分发状态保存过程,保存该组件及其子组件的状态。 <T extends Component>T findComponentById(int id) 查找具有给定 ID 的组件。 ComponentHolder findComponentHolderById(int resId) 使用资源 id 获取 componentHolder 的实例。 boolean getAutoLayout() 获取是否启用自动布局。 int getChildCount() 获取子组件的数量。 int getChildIndex(Component component) 查询子组件的位置。 Component getComponentAt(int index) 使用索引获取子组件。 ComponentTransition getComponentTransition() 获取组件的 ComponentTransition 对象。 int getFocusOrder() 获取此组件相对于其后代的可聚焦性。 LayoutManager getLayoutManager() 获取一个LayoutManager对象,用于对相关子组件进行布局。 void informConfigurationChanged(Configuration config) 调度配置更改事件。 boolean isClipToChildBoundsEnabled() 获取子组件的绘制范围是否可以超出子组件的边界。 boolean...

鸿蒙OS Component.VoiceEvent

Component.VoiceEvent java.lang.Object |—ohos.agp.components.Component.VoiceEvent public static class Component.VoiceEvent extends Object 为组件提供语音事件。 构造函数摘要 构造函数 描述 VoiceEvent(String speech) 用于根据热门词创建 VoiceEvent 实例的构造函数。 VoiceEvent(String speech, int scene, boolean isUseBadge) 用于根据热词、事件场景以及是否使用事件徽章创建 VoiceEvent 实例的构造函数。 方法总结 修饰符和类型 方法 描述 void addBadges(String from, String to) 设置场景的开始和结束事件徽章。 void addSynonyms(String synonyms) 向语音事件添加同义词。 ListString[] getBadge() 获取事件徽章。 int getScene() 获取事件场景。 String getSpeech() 获取事件语音。 ListString getSynonyms() 获取事件同义词。 void sendDataToComponent(Component component) 将此对象绑定到组件。 void setBadge(boolean enable) 设置事件徽章。 void setScene(int scene) 设置事件场景。 从类 java.lang.Object 继承的方法 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 构造函数详细信息 VoiceEvent public VoiceEvent(String speech, int scene, boolean isUseBadge) 用于根据热词、事件场景以及是否使用事件徽章创建 VoiceEvent 实例的构造函数。 参数: 参数名称 参数描述 speech 表示热词。 scene 指示使用此事件的场景。 isUseBadge 指定是否使用事件徽章。 值 true 表示使用徽章,false 表示相反。 VoiceEvent public VoiceEvent(String speech) 用于根据热门词创建 VoiceEvent 实例的构造函数。 参数: 参数名称 参数描述 speech 表示热词。 方法详情 addSynonyms public void addSynonyms(String synonyms) 向语音事件添加同义词。 参数: 参数名称 参数描述 synonyms 表示要添加的同义词。 setScene public void setScene(int scene) 设置事件场景。 参数: 参数名称 参数描述 scene 指示将使用事件的场景。 setBadge public void setBadge(boolean enable) 设置事件徽章。 参数: 参数名称 参数描述 enable 指定是否启用事件标记。 值 true 表示启用标记,false 表示禁用标记。 addBadges...