鴻蒙OS ComponentContainer

2022-09-19 16:54 更新

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 提供布局參數(shù),例如寬度和高度以及邊距。
從類 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 指示此組件在其任何子項(xiàng)之前獲得焦點(diǎn)。
static int FOCUS_CHILDREN_HIDE 指示此組件阻止其子級獲得焦點(diǎn),即使它們是可聚焦的。
static int FOCUS_PARENT_FIRST 指示僅當(dāng)其子組件均未請求焦點(diǎn)時(shí),此組件才獲得焦點(diǎn)。
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

構(gòu)造函數(shù)摘要

構(gòu)造函數(shù) 描述
ComponentContainer(Context context) 默認(rèn)構(gòu)造函數(shù)用于使用默認(rèn)屬性集和樣式創(chuàng)建 ComponentContainer 實(shí)例。
ComponentContainer(Context context, AttrSet attrSet) 用于在 XML 文件解析后使用指定的屬性集和默認(rèn)樣式創(chuàng)建 ComponentContainer 實(shí)例的構(gòu)造函數(shù)。
ComponentContainer(Context context, AttrSet attrSet, String styleName) 一個(gè)構(gòu)造函數(shù),用于在解析 XML 文件后使用指定的屬性集和指定的樣式創(chuàng)建一個(gè) ComponentContainer 實(shí)例。

方法總結(jié)

修飾符和類型 方法 描述
void addComponent(Component childComponent) 通過在內(nèi)部調(diào)用 addComponent(ohos.agp.components.Component,int index) 將組件添加到隊(duì)列的末尾。
void addComponent(Component childComponent, int index) 將組件添加到指定位置。
void addComponent(Component childComponent, int width, int height) 添加一個(gè)組件并設(shè)置其寬度和高度。
void addComponent(Component childComponent, int index, ComponentContainer.LayoutConfig layoutConfig) 添加組件并設(shè)置其布局參數(shù)和位置。
void addComponent(Component childComponent, ComponentContainer.LayoutConfig layoutConfig) 添加一個(gè)組件并設(shè)置其布局參數(shù)。
ComponentContainer.LayoutConfig createLayoutConfig(Context context, AttrSet attrSet) 使用子組件的屬性集創(chuàng)建布局參數(shù)。
protected void dispatchRestoreState(PlainArraySequenceable stateContainer) 分發(fā)狀態(tài)恢復(fù)過程來恢復(fù)該組件及其子組件的狀態(tài)。
protected void dispatchSaveState(PlainArraySequenceable stateContainer) 分發(fā)狀態(tài)保存過程,保存該組件及其子組件的狀態(tài)。
<T extends Component>T findComponentById(int id) 查找具有給定 ID 的組件。
ComponentHolder findComponentHolderById(int resId) 使用資源 id 獲取 componentHolder 的實(shí)例。
boolean getAutoLayout() 獲取是否啟用自動(dòng)布局。
int getChildCount() 獲取子組件的數(shù)量。
int getChildIndex(Component component) 查詢子組件的位置。
Component getComponentAt(int index) 使用索引獲取子組件。
ComponentTransition getComponentTransition() 獲取組件的 ComponentTransition 對象。
int getFocusOrder() 獲取此組件相對于其后代的可聚焦性。
LayoutManager getLayoutManager() 獲取一個(gè)LayoutManager對象,用于對相關(guān)子組件進(jìn)行布局。
void informConfigurationChanged(Configuration config) 調(diào)度配置更改事件。
boolean isClipToChildBoundsEnabled() 獲取子組件的繪制范圍是否可以超出子組件的邊界。
boolean isClipToPaddingBoundsEnabled() 獲取組件的繪制范圍是否可以超出其填充邊界的邊界。
boolean isTouchEventSplitable() 獲取此 ComponentContainer 的觸摸事件是否可以拆分。
void moveChildToFront(Component component) 將子組件置于最前面。
boolean onDrag(Component component, DragEvent event) 在將拖動(dòng)事件分派到組件時(shí)調(diào)用。
void removeAllComponents() 清除 ComponentContainer 管理的所有組件。
void removeComponent(Component component) 從父組件中移除子組件。
void removeComponentAt(int index) 從組件列表中的指定位置移除組件。
void removeComponentById(int id) 根據(jù) ID 移除組件。
void removeComponents(int start, int count) 從組件列表中的指定位置移除所有組件。
protected void setArrangeListener(ComponentContainer.ArrangeListener listener) 在組件容器的排列過程中添加一個(gè)監(jiān)聽器。
void setAutoLayout(boolean autoLayout) 設(shè)置是否啟用自動(dòng)布局。
void setAutoLayout(boolean autoLayout, int columnType) 設(shè)置是否啟用自動(dòng)布局并設(shè)置列類型。
void setClipToChildBoundsEnabled(boolean enable) 控制子組件的繪制范圍是否可以超出子組件的邊界。
void setClipToPaddingBoundsEnabled(boolean enable) 控制組件的繪制范圍是否可以超出其填充邊界的邊界。
void setComponentTransition(ComponentTransition componentTransition) 設(shè)置一個(gè) ComponentTransition 對象。
void setFocusOrder(int focusability) 設(shè)置此組件相對于其后代的可聚焦性。
void setLayoutManager(LayoutManager layoutManager) 設(shè)置一個(gè) LayoutManager 實(shí)例,用于布局相關(guān)子組件。
void setTouchEventSplitable(boolean enable) 控制是否將拆分觸摸事件分派給多個(gè)子組件。
ComponentContainer.LayoutConfig verifyLayoutConfig(ComponentContainer.LayoutConfig config) 根據(jù)當(dāng)前布局類型驗(yàn)證布局參數(shù)。
從類 ohos.agp.components.Component 繼承的方法
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, unsubscribeVoiceEvents
從接口 ohos.agp.components.ComponentParent 繼承的方法
getComponentParent, postLayout
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

字段詳細(xì)信息

FOCUS_CHILDREN_FIRST

public static final int FOCUS_CHILDREN_FIRST

指示此組件在其任何子項(xiàng)之前獲得焦點(diǎn)。

FOCUS_CHILDREN_HIDE

public static final int FOCUS_CHILDREN_HIDE

指示此組件阻止其子級獲得焦點(diǎn),即使它們是可聚焦的。

FOCUS_PARENT_FIRST

public static final int FOCUS_PARENT_FIRST

指示僅當(dāng)其子組件均未請求焦點(diǎn)時(shí),此組件才獲得焦點(diǎn)。

mArrangeListener

protected ComponentContainer.ArrangeListener mArrangeListener

在排列過程中自定義子組件的排列

構(gòu)造函數(shù)詳細(xì)信息

ComponentContainer

public ComponentContainer(Context context)

默認(rèn)構(gòu)造函數(shù)用于使用默認(rèn)屬性集和樣式創(chuàng)建 ComponentContainer 實(shí)例。

參數(shù):

參數(shù)名稱 參數(shù)描述
context 指示應(yīng)用程序上下文。

ComponentContainer

public ComponentContainer(Context context, AttrSet attrSet)

用于在 XML 文件解析后使用指定的屬性集和默認(rèn)樣式創(chuàng)建 ComponentContainer 實(shí)例的構(gòu)造函數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
context 指示應(yīng)用程序上下文。
attrSet 指示要使用的屬性集。

ComponentContainer

public ComponentContainer(Context context, AttrSet attrSet, String styleName)

一個(gè)構(gòu)造函數(shù),用于在解析 XML 文件后使用指定的屬性集和指定的樣式創(chuàng)建一個(gè) ComponentContainer 實(shí)例。

參數(shù):

參數(shù)名稱 參數(shù)描述
context 指示應(yīng)用程序上下文。
attrSet 指示要使用的屬性集。
styleName 指示要使用的樣式名稱。

方法詳情

verifyLayoutConfig

public ComponentContainer.LayoutConfig verifyLayoutConfig(ComponentContainer.LayoutConfig config)

根據(jù)當(dāng)前布局類型驗(yàn)證布局參數(shù)。

指定者:

接口 ComponentParent 中的 verifyLayoutConfig

參數(shù):

參數(shù)名稱 參數(shù)描述
config 指示要轉(zhuǎn)換為 ComponentContainer 實(shí)例的一組布局參數(shù)。

返回:

返回 LayoutConfig 實(shí)例,它表示布局參數(shù)。

createLayoutConfig

public ComponentContainer.LayoutConfig createLayoutConfig(Context context, AttrSet attrSet)

使用子組件的屬性集創(chuàng)建布局參數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
context 指示應(yīng)用程序上下文。
attrSet 表示屬性集。

返回:

返回創(chuàng)建的布局參數(shù)。

setArrangeListener

protected void setArrangeListener(ComponentContainer.ArrangeListener listener)

在組件容器的排列過程中添加一個(gè)監(jiān)聽器。

參數(shù):

參數(shù)名稱 參數(shù)描述
listener 指定組件容器的排列偵聽器。

findComponentById

public <T extends Component> T findComponentById(int id)

查找具有給定 ID 的組件。

如果當(dāng)前組件本身的 ID 與給定 ID 匹配,則返回當(dāng)前組件。 否則,返回 null。

覆蓋:

組件類中的 findComponentById

參數(shù):

參數(shù)名稱 參數(shù)描述
id 表示組件的唯一標(biāo)識符。

返回:

返回 ID 與給定 ID 匹配的組件; 如果沒有找到組件,則返回 null。

addComponent

public void addComponent(Component childComponent)

通過在內(nèi)部調(diào)用 addComponent(ohos.agp.components.Component,int index) 將組件添加到隊(duì)列的末尾。

參數(shù):

參數(shù)名稱 參數(shù)描述
childComponent 指示要添加的子組件。

addComponent

public void addComponent(Component childComponent, int width, int height)

添加一個(gè)組件并設(shè)置其寬度和高度。

參數(shù):

參數(shù)名稱 參數(shù)描述
childComponent 指示要添加的子組件。
width 指示子組件的寬度,以像素為單位。
height 指示子組件的高度,以像素為單位。

addComponent

public void addComponent(Component childComponent, ComponentContainer.LayoutConfig layoutConfig)

添加一個(gè)組件并設(shè)置其布局參數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
childComponent 指示要添加的子組件。
layoutConfig 表示子組件的布局參數(shù)。

addComponent

public void addComponent(Component childComponent, int index, ComponentContainer.LayoutConfig layoutConfig)

添加組件并設(shè)置其布局參數(shù)和位置。

參數(shù):

參數(shù)名稱 參數(shù)描述
childComponent 指示要添加的子組件。
index 指示添加子組件的位置。 值 -1 表示將子組件添加到隊(duì)列的末尾。
layoutConfig 表示子組件的布局參數(shù)。

addComponent

public void addComponent(Component childComponent, int index)

將組件添加到指定位置。

如果沒有為該子組件設(shè)置布局參數(shù),則使用 ComponentContainer 的默認(rèn)布局參數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
childComponent 指示要添加的子組件。
index 指示添加子組件的位置。 值 -1 表示將組件添加到末尾。 如果提供的數(shù)字大于 getChildCount() 的值,則返回運(yùn)行時(shí)異常。

getComponentAt

public Component getComponentAt(int index)

使用索引獲取子組件。

ComponentContainer 使用內(nèi)部列表來存儲子組件信息。 您可以使用索引獲取指定的子組件。

參數(shù):

參數(shù)名稱 參數(shù)描述
index 表示子組件的索引。

返回:

返回子組件。

getChildIndex

public int getChildIndex(Component component)

查詢子組件的位置。

指定者:

接口 ComponentParent 中的 getChildIndex

參數(shù):

參數(shù)名稱 參數(shù)描述
component 指示要查詢的子組件。

返回:

返回一個(gè)正整數(shù),表示子組件在父組件中的位置; 如果子組件不包含在父組件中,則返回 -1。

findComponentHolderById

public ComponentHolder findComponentHolderById(int resId)

使用資源 id 獲取 componentHolder 的實(shí)例。

覆蓋:

組件類中的 findComponentHolderById

參數(shù):

參數(shù)名稱 參數(shù)描述
resId componentHolder 的資源 ID。

返回:

componentHolder 的實(shí)例。

removeComponent

public void removeComponent(Component component)

從父組件中移除子組件。

指定者:

接口 ComponentParent 中的 removeComponent

參數(shù):

參數(shù)名稱 參數(shù)描述
component 指示要移除的子組件。

removeComponentAt

public void removeComponentAt(int index)

從組件列表中的指定位置移除組件。

指定者:

接口 ComponentParent 中的 removeComponentAt

參數(shù):

參數(shù)名稱 參數(shù)描述
index 指示要移除的組件的位置索引。

removeComponentById

public void removeComponentById(int id)

根據(jù) ID 移除組件。

參數(shù):

參數(shù)名稱 參數(shù)描述
id 表示組件ID。

removeComponents

public void removeComponents(int start, int count)

從組件列表中的指定位置移除所有組件。

指定者:

接口 ComponentParent 中的 removeComponents

參數(shù):

參數(shù)名稱 參數(shù)描述
start 表示第一個(gè)移除的組件的位置索引。
count 表示要移除的組件數(shù)量。

removeAllComponents

public void removeAllComponents()

清除 ComponentContainer 管理的所有組件。

moveChildToFront

public void moveChildToFront(Component component)

將子組件置于最前面。

指定者:

接口 ComponentParent 中的 moveChildToFront

參數(shù):

參數(shù)名稱 參數(shù)描述
component 指示要放在前面的組件。

getChildCount

public int getChildCount()

獲取子組件的數(shù)量。

返回:

返回子組件的數(shù)量。

informConfigurationChanged

public void informConfigurationChanged(Configuration config)

從類復(fù)制的描述:組件

調(diào)度配置更改事件。 事件處理邏輯由 Component.onAttributeConfigChanged(ohos.global.configuration.Configuration) 實(shí)現(xiàn)。

覆蓋:

類 Component 中的 informConfigurationChanged

參數(shù):

參數(shù)名稱 參數(shù)描述
config 表示最新配置。

getFocusOrder

public int getFocusOrder()

獲取此組件相對于其后代的可聚焦性。

目前,這僅影響非觸摸焦點(diǎn)更改。

返回:

返回可聚焦性,可以是 FOCUS_PARENT_FIRST、FOCUS_CHILDREN_FIRST 或 FOCUS_CHILDREN_HIDE。

setFocusOrder

public void setFocusOrder(int focusability)

設(shè)置此組件相對于其后代的可聚焦性。

目前,這僅影響非觸摸焦點(diǎn)更改。

參數(shù):

參數(shù)名稱 參數(shù)描述
focusability 表示可聚焦性,可以是 FOCUS_PARENT_FIRST、FOCUS_CHILDREN_FIRST 或 FOCUS_CHILDREN_HIDE。

setAutoLayout

public void setAutoLayout(boolean autoLayout)

設(shè)置是否啟用自動(dòng)布局。

參數(shù):

參數(shù)名稱 參數(shù)描述
autoLayout 指示自動(dòng)布局狀態(tài)。 true 表示啟用自動(dòng)布局,false 表示禁用它。

setAutoLayout

public void setAutoLayout(boolean autoLayout, int columnType)

設(shè)置是否啟用自動(dòng)布局并設(shè)置列類型。

參數(shù):

參數(shù)名稱 參數(shù)描述
autoLayout true 表示啟用自動(dòng)布局,false 表示禁用它。
columnType 指示要使用的列類型。

getAutoLayout

public boolean getAutoLayout()

獲取是否啟用自動(dòng)布局。

返回:

如果啟用了自動(dòng)布局,則返回 true; 否則返回 false。

onDrag

public boolean onDrag(Component component, DragEvent event)

在將拖動(dòng)事件分派到組件時(shí)調(diào)用。

指定者:

接口 ComponentParent 中的 onDrag

覆蓋:

類 Component 中的 onDrag

參數(shù):

參數(shù)名稱 參數(shù)描述
component 表示組件。
event 表示拖動(dòng)事件。

返回:

如果正確處理了拖動(dòng)事件,則返回 true; 否則返回 false。

setLayoutManager

public void setLayoutManager(LayoutManager layoutManager)

設(shè)置一個(gè) LayoutManager 實(shí)例,用于布局相關(guān)子組件。

參數(shù):

參數(shù)名稱 參數(shù)描述
layoutManager 指示要設(shè)置的布局管理器。

getLayoutManager

public LayoutManager getLayoutManager()

獲取一個(gè)LayoutManager對象,用于對相關(guān)子組件進(jìn)行布局。

返回:

返回此組件容器的 LayoutManager 對象。

setComponentTransition

public void setComponentTransition(ComponentTransition componentTransition)

設(shè)置一個(gè) ComponentTransition 對象。

參數(shù):

參數(shù)名稱 參數(shù)描述
componentTransition 指示要使用的 ComponentTransition 對象。 此參數(shù)不能為空。

getComponentTransition

public ComponentTransition getComponentTransition()

獲取組件的 ComponentTransition 對象。

返回:

返回 ComponentTransition 對象。

setClipToChildBoundsEnabled

public void setClipToChildBoundsEnabled(boolean enable)

控制子組件的繪制范圍是否可以超出子組件的邊界。

參數(shù):

參數(shù)名稱 參數(shù)描述
enable true 表示允許子組件的繪制范圍超出自己的邊界,false 表示相反。

isClipToChildBoundsEnabled

public boolean isClipToChildBoundsEnabled()

獲取子組件的繪制范圍是否可以超出子組件的邊界。

返回:

返回子組件的繪制范圍是否可以超出子組件的邊界。

setClipToPaddingBoundsEnabled

public void setClipToPaddingBoundsEnabled(boolean enable)

控制組件的繪制范圍是否可以超出其填充邊界的邊界。

參數(shù):

參數(shù)名稱 參數(shù)描述
enable 值 true 表示允許組件的繪制范圍超出其填充邊界的邊界,false 表示相反。

isClipToPaddingBoundsEnabled

public boolean isClipToPaddingBoundsEnabled()

獲取組件的繪制范圍是否可以超出其填充邊界的邊界。

返回:

返回組件的繪制范圍是否可以超出其填充邊界的邊界。

setTouchEventSplitable

public void setTouchEventSplitable(boolean enable)

控制是否將拆分觸摸事件分派給多個(gè)孩子。 默認(rèn)情況下禁用該功能。

參數(shù):

參數(shù)名稱 參數(shù)描述
enable 值 true 表示允許將拆分觸摸事件分派給多個(gè)孩子,false 表示不允許。

isTouchEventSplitable

public boolean isTouchEventSplitable()

獲取此 ComponentContainer 的觸摸事件是否可以拆分。

返回:

如果派發(fā)到此 ComponentContainer 的觸摸事件可以拆分到多個(gè)子級,則為 true。

dispatchSaveState

protected void dispatchSaveState(PlainArraySequenceable stateContainer)

分發(fā)狀態(tài)保存過程,保存該組件及其子組件的狀態(tài)。

覆蓋:

組件類中的 dispatchSaveState

參數(shù):

參數(shù)名稱 參數(shù)描述
stateContainer 指示保存狀態(tài)信息的容器。

dispatchRestoreState

protected void dispatchRestoreState(PlainArraySequenceable stateContainer)

分發(fā)狀態(tài)恢復(fù)過程來恢復(fù)該組件及其子組件的狀態(tài)。

覆蓋:

組件類中的 dispatchRestoreState

參數(shù):

參數(shù)名稱 參數(shù)描述
stateContainer 表示保存待恢復(fù)狀態(tài)信息的容器。
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號