ComponentParentAdaptiveBoxLayout, DependentLayout, DirectionalLayout, FlexLayout, ListComponent, ListContainer, MagicLayout, PositionLayout, SlideDrawer, StackLayout, TableLayoutpublic abstract class ComponentContainer extends Component implements ComponentParent
This layout base class inherits from Component.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
ComponentContainer.ArrangeListener |
Provides an interface for customizing the component arrangement process.
|
static class |
ComponentContainer.LayoutConfig |
Provides layout parameters, such as width and height and margin.
|
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 |
Indicates that this component takes focus before any of its children.
|
static int |
FOCUS_CHILDREN_HIDE |
Indicates that this component blocks its children from getting focus, even if they are focusable.
|
static int |
FOCUS_PARENT_FIRST |
Indicates that this component takes focus only if none of its children request focus.
|
protected ComponentContainer.ArrangeListener |
mArrangeListener |
Customizes children components' arrangement during arrange process
|
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) |
Default constructor used to create a
ComponentContainer instance by using the default attribute set
and style. |
ComponentContainer(Context context,
AttrSet attrSet) |
A constructor used to create a
ComponentContainer instance by using specified attribute set and default
style after the XML file is parsed. |
ComponentContainer(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
ComponentContainer instance by using specified attribute set and
specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addComponent(Component childComponent) |
Adds a component to the end of the queue by invoking
addComponent(ohos.agp.components.Component,int index) internally. |
void |
addComponent(Component childComponent,
int index) |
Adds a component to the specified position.
|
void |
addComponent(Component childComponent,
int width,
int height) |
Adds a component and sets its width and height.
|
void |
addComponent(Component childComponent,
int index,
ComponentContainer.LayoutConfig layoutConfig) |
Adds a component and sets its layout parameters and location.
|
void |
addComponent(Component childComponent,
ComponentContainer.LayoutConfig layoutConfig) |
Adds a component and sets its layout parameters.
|
ComponentContainer.LayoutConfig |
createLayoutConfig(Context context,
AttrSet attrSet) |
Creates layout parameters using the attribute set of a child component.
|
protected void |
dispatchRestoreState(PlainArray<Sequenceable> stateContainer) |
Distribute the state restore process to restore the states of this component and its child components.
|
protected void |
dispatchSaveState(PlainArray<Sequenceable> stateContainer) |
Distribute the state saving process to save the states of this component and its child components.
|
<T extends Component> |
findComponentById(int id) |
Finds the component with the given ID.
|
ComponentHolder |
findComponentHolderById(int resId) |
Gets an instance of componentHolder using resource id.
|
boolean |
getAutoLayout() |
Obtains whether automatic layout is enabled.
|
int |
getChildCount() |
Obtains the quantity of child components.
|
int |
getChildIndex(Component component) |
Queries the position of a child component.
|
Component |
getComponentAt(int index) |
Obtains a child component using an index.
|
ComponentTransition |
getComponentTransition() |
Obtains the
ComponentTransition object of the component. |
int |
getFocusOrder() |
Obtains the focusability of this component relative to its descendants.
|
LayoutManager |
getLayoutManager() |
Obtains a
LayoutManager object, which is used to lay out relevant child components. |
void |
informConfigurationChanged(Configuration config) |
Dispatches a configuration change event.
|
boolean |
isClipToChildBoundsEnabled() |
Obtains whether the drawing range of a child component can exceed the boundary of the child component.
|
boolean |
isClipToPaddingBoundsEnabled() |
Obtains whether the drawing range of a component can exceed the boundary of its padding bounds.
|
boolean |
isTouchEventSplitable() |
Obtains whether the touch events of this ComponentContainer can be split.
|
void |
moveChildToFront(Component component) |
Brings a child component to the front.
|
boolean |
onDrag(Component component,
DragEvent event) |
Called when a drag event is dispatched to the component.
|
void |
removeAllComponents() |
Clears all components managed by
ComponentContainer. |
void |
removeComponent(Component component) |
Removes a child component from the parent component.
|
void |
removeComponentAt(int index) |
Removes the component from a specified position in the component list.
|
void |
removeComponentById(int id) |
Removes a component based on its ID.
|
void |
removeComponents(int start,
int count) |
Removes all components from specified positions in a component list.
|
protected void |
setArrangeListener(ComponentContainer.ArrangeListener listener) |
Adds a listener on component-container's arrangement process.
|
void |
setAutoLayout(boolean autoLayout) |
Sets whether to enable automatic layout.
|
void |
setAutoLayout(boolean autoLayout,
int columnType) |
Sets whether to enable automatic layout and set the column type.
|
void |
setClipToChildBoundsEnabled(boolean enable) |
Controls whether the drawing range of a child component can exceed the boundary of the child component.
|
void |
setClipToPaddingBoundsEnabled(boolean enable) |
Controls whether the drawing range of a component can exceed the boundary of its padding bounds.
|
void |
setComponentTransition(ComponentTransition componentTransition) |
Sets a
ComponentTransition object. |
void |
setFocusOrder(int focusability) |
Sets the focusability of this component relative to its descendants.
|
void |
setLayoutManager(LayoutManager layoutManager) |
Sets a
LayoutManager instance, which is used to lay out relevant child components. |
void |
setTouchEventSplitable(boolean enable) |
Controls whether dispatch split touch event to multiple children.
|
ComponentContainer.LayoutConfig |
verifyLayoutConfig(ComponentContainer.LayoutConfig config) |
Verifies layout parameters based on the current layout type.
|
addDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findFocus, findNextFocusableComponent, findRequestNextFocus, getAccessibility, getAccessibilityDescription, getAlpha, getAltitude, getBackgroundElement, getBaseLine, getBottom, getBoundaryFadeEffectBottomRate, getBoundaryFadeEffectLeftRate, getBoundaryFadeEffectRightRate, getBoundaryFadeEffectTopRate, getCenterZoomFactor, getCentralScrollMode, getClickedListener, getClipEnabled, getComponentDescription, getComponentMinSize, getComponentParent, getComponentPosition, getComponentSize, getComponentStateChangedListener, getComponentTreeObserver, getContentEnable, getContentPosition, getContentPositionX, getContentPositionY, getContext, getContour, getContourRefreshedListener, getCornerMark, getDragAcceptAngle, getDraggedListener, getEditEventListener, getEstimatedHeight, getEstimatedWidth, getFadeEffectBoundaryWidth, getFadeEffectColor, getFocusable, getFocusBorderEnable, getFocusBorderPadding, getFocusBorderRadius, getFocusBorderWidth, getForegroundElement, getForegroundGravity, getForwardHoverListener, getForwardTouchListener, getGesturePriority, getHeight, getHorizontalPadding, getHorizontalPosition, getHoverEventListener, getId, getKeyEventListener, getLayoutConfig, getLayoutDirection, getLayoutDirectionResolved, getLayoutRefreshedListener, getLeft, getLocationOnScreen, getMarginBottom, getMarginLeft, getMarginRight, getMargins, getMarginsLeftAndRight, getMarginsTopAndBottom, getMarginTop, getMatrix, getMinHeight, getMinWidth, getMode, getModeResolved, getMouseEventListener, getMousePointerStyleListener, getName, getPadding, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getPivot, getPivotX, getPivotY, getResourceManager, getRight, getRotation, getRotationEventListener, getRotationSensitivity, getScale, getScaledListener, getScaleX, getScaleY, getScrollbarBackgroundColor, getScrollbarColor, getScrollbarFadingDelay, getScrollbarFadingDuration, getScrollBarMode, getScrollbarRadius, getScrollbarRoundRect, getScrollbarStartAngle, getScrollbarSweepAngle, getScrollbarThickness, getScrollState, getScrollValue, getSelfVisibleRect, getShadowColor, getSpeechEventListener, getTag, getTop, getTouchEventListener, getTransitionSymbol, getTranslation, getTranslationX, getTranslationY, getTranslationZ, getUserNextFocus, getVerticalPadding, getVerticalPosition, getVisibility, getVisibleRectOnScreen, getWidth, getWindowVisibleRect, hasFocus, hasFocusedEffect, hasOverlaps, hideFocusBorder, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onRestoreState, onRtlChanged, onSaveState, performScale, playSound, postLayout, refreshContour, release, removeBindStateChangedListener, removeScrolledListener, requestFocus, requestForceForwardTouchEvent, restoreComponentTreeState, saveComponentTreeState, scrollBy, scrollTo, setAccessibility, setAccessibilityDescription, setAlpha, setAltitude, setBackground, setBindStateChangedListener, setBottom, setBoundaryFadeEffectEnable, setCanAcceptScrollListener, setCenterZoomFactor, setCentralScrollMode, setClickable, setClickedListener, setClipEnabled, setClipToContourEnabled, setComponentDescription, setComponentMinSize, setComponentPosition, setComponentPosition, setComponentSize, setComponentStateChangedListener, setContentEnable, setContentPosition, setContentPositionX, setContentPositionY, setContour, setContourRefreshedListener, setDoubleClickedListener, setDragAcceptAngle, setDraggedListener, setEditEventListener, setEnabled, setEstimatedSize, setEstimateSizeListener, setFadeEffectBoundaryWidth, setFadeEffectColor, setFocusable, setFocusBorderEnable, setFocusBorderPadding, setFocusBorderRadius, setFocusBorderRadius, setFocusBorderWidth, setFocusChangedListener, setFocusedEffect, setForeground, setForegroundGravity, setForwardHoverListener, setForwardTouchListener, setGesturePriority, setHeight, setHorizontalPadding, setHorizontalPosition, setHoverEventListener, setId, setKeyEventListener, setLayoutConfig, setLayoutDirection, setLayoutRefreshedListener, setLeft, setLongClickable, setLongClickedListener, setMarginBottom, setMarginLeft, setMarginRight, setMarginsLeftAndRight, setMarginsTopAndBottom, setMarginTop, setMinHeight, setMinWidth, setMode, setMouseEventListener, setMousePointerStyleListener, setName, setOnDragListener, setPadding, setPaddingBottom, setPaddingLeft, setPaddingRelative, setPaddingRight, setPaddingTop, setPivot, setPivot, setPivotX, setPivotY, setPosition, setPositionX, setPositionY, setPressState, setRight, setRotation, setRotationEventListener, setRotationSensitivity, setScale, setScaledListener, setScaleX, setScaleY, setScrollbarBackgroundColor, setScrollbarColor, setScrollbarFadingDelay, setScrollbarFadingDuration, setScrollbarFadingEnabled, setScrollBarMode, setScrollbarOverlapEnabled, setScrollbarRadius, setScrollbarRoundRect, setScrollbarStartAngle, setScrollbarSweepAngle, setScrollbarThickness, setScrolledListener, setSelected, setShadowColor, setShadowStyle, setSoundEnable, setSpeechEventListener, setTag, setTop, setTouchEventListener, setTouchFocusable, setTransitionSymbol, setTranslation, setTranslationX, setTranslationY, setTranslationZ, setUnconsumedKeyEventListener, setUserNextFocus, setVerticalPadding, setVerticalPosition, setVibrationEffectEnabled, setVisibility, setWidth, showFocusBorder, simulateClick, simulateDrag, startDragAndDrop, subscribeVoiceEvents, unsubscribeVoiceEventsgetComponentParent, postLayoutpublic static final int FOCUS_CHILDREN_FIRST
setFocusOrder(int),
常量字段值public static final int FOCUS_CHILDREN_HIDE
setFocusOrder(int),
常量字段值public static final int FOCUS_PARENT_FIRST
setFocusOrder(int),
常量字段值protected ComponentContainer.ArrangeListener mArrangeListener
public ComponentContainer(Context context)
ComponentContainer instance by using the default attribute set
and style.context - Indicates the application context.public ComponentContainer(Context context, AttrSet attrSet)
ComponentContainer instance by using specified attribute set and default
style after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public ComponentContainer(Context context, AttrSet attrSet, String styleName)
ComponentContainer instance by using specified attribute set and
specified style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public ComponentContainer.LayoutConfig verifyLayoutConfig(ComponentContainer.LayoutConfig config)
verifyLayoutConfig 在接口中 ComponentParentconfig - Indicates a group of layout parameters to be converted into a ComponentContainer instance.LayoutConfig instance, which represents the layout parameters.public ComponentContainer.LayoutConfig createLayoutConfig(Context context, AttrSet attrSet)
context - Indicates the application context.attrSet - Indicates the attribute set.protected void setArrangeListener(ComponentContainer.ArrangeListener listener)
listener - Specifies the arrangement listener for a component container.ComponentContainer.ArrangeListenerpublic <T extends Component> T findComponentById(int id)
If the ID of the current component itself matches the given ID, the current component is returned. Otherwise,
null is returned.
findComponentById 在类中 Componentid - Indicates a unique identifier of a component.null if no component is found.public void addComponent(Component childComponent)
addComponent(ohos.agp.components.Component,int index) internally.childComponent - Indicates the child component to add.public void addComponent(Component childComponent, int width, int height)
childComponent - Indicates the child component to add.width - Indicates the width of the child component, in pixels.height - Indicates the height of the child component, in pixels.public void addComponent(Component childComponent, ComponentContainer.LayoutConfig layoutConfig)
childComponent - Indicates the child component to add.layoutConfig - Indicates the layout parameters of the child component.public void addComponent(Component childComponent, int index, ComponentContainer.LayoutConfig layoutConfig)
childComponent - Indicates the child component to add.index - Indicates where to add the child component. The value -1 means to add the child
component to the end of the queue.layoutConfig - Indicates the layout parameters of the child component.public void addComponent(Component childComponent, int index)
If no layout parameters are set for this child component, the default layout parameters of
ComponentContainer are used.
childComponent - Indicates the child component to add.index - Indicates where to add the child component. The value -1 means to add the
component to the end. If a number greater than the value of getChildCount() is
provided, a runtime exception is returned.public Component getComponentAt(int index)
ComponentContainer uses an internal list to store child component information. You can obtain specified
child components
using the index.
index - Indicates the index of child components.public int getChildIndex(Component component)
getChildIndex 在接口中 ComponentParentcomponent - Indicates the child component to query.-1 if the child component is not included in the parent component.public ComponentHolder findComponentHolderById(int resId)
findComponentHolderById 在类中 ComponentresId - Resource id of componentHolder.public void removeComponent(Component component)
removeComponent 在接口中 ComponentParentcomponent - Indicates the child component to remove.public void removeComponentAt(int index)
removeComponentAt 在接口中 ComponentParentindex - Indicates the position index of the component to remove.public void removeComponentById(int id)
id - Indicates the component ID.public void removeComponents(int start,
int count)
removeComponents 在接口中 ComponentParentstart - Indicates the position index of the first removed component.count - Indicates the quantity of components to remove.public void removeAllComponents()
ComponentContainer.public void moveChildToFront(Component component)
moveChildToFront 在接口中 ComponentParentcomponent - Indicates the component to bring to the front.public int getChildCount()
public void informConfigurationChanged(Configuration config)
ComponentComponent.onAttributeConfigChanged(ohos.global.configuration.Configuration).informConfigurationChanged 在类中 Componentconfig - Indicates the latest configuration.Component.onAttributeConfigChanged(Configuration)public int getFocusOrder()
Currently, this affects non-touch focus changes only.
FOCUS_PARENT_FIRST,
FOCUS_CHILDREN_FIRST, or FOCUS_CHILDREN_HIDE.public void setFocusOrder(int focusability)
Currently, this affects non-touch focus changes only.
focusability - Indicates the focusability, which can be FOCUS_PARENT_FIRST,
FOCUS_CHILDREN_FIRST, or FOCUS_CHILDREN_HIDE.public void setAutoLayout(boolean autoLayout)
autoLayout - Indicates the automatic layout status. true means to enable automatic layout, and
false means to disable it.public void setAutoLayout(boolean autoLayout,
int columnType)
autoLayout - true means to enable automatic layout, and false means to disable it.columnType - Indicates the column type to use.public boolean getAutoLayout()
true if automatic layout is enabled; returns false otherwise.public boolean onDrag(Component component, DragEvent event)
onDrag 在接口中 ComponentParentonDrag 在类中 Componentcomponent - Indicates the component.event - Indicates the drag event.true if the drag event is processed correctly; returns false otherwise.public void setLayoutManager(LayoutManager layoutManager)
LayoutManager instance, which is used to lay out relevant child components.layoutManager - Indicates the layout manager to set.public LayoutManager getLayoutManager()
LayoutManager object, which is used to lay out relevant child components.LayoutManager object of this component container.public void setComponentTransition(ComponentTransition componentTransition)
ComponentTransition object.componentTransition - Indicates the ComponentTransition object to be used. This parameter
can not be null.ComponentTransitionpublic ComponentTransition getComponentTransition()
ComponentTransition object of the component.ComponentTransition object.public void setClipToChildBoundsEnabled(boolean enable)
public boolean isClipToChildBoundsEnabled()
public void setClipToPaddingBoundsEnabled(boolean enable)
public boolean isClipToPaddingBoundsEnabled()
public void setTouchEventSplitable(boolean enable)
enable - true means allowing to dispatch split touch event to multiple children, and false
means not allow.public boolean isTouchEventSplitable()
protected void dispatchSaveState(PlainArray<Sequenceable> stateContainer)
dispatchSaveState 在类中 ComponentstateContainer - Indicates the container to hold the state information.protected void dispatchRestoreState(PlainArray<Sequenceable> stateContainer)
dispatchRestoreState 在类中 ComponentstateContainer - Indicates the container that holds the state information to be restored.