文档管理中心

AdaptiveBoxLayout

java.lang.Object

|---ohos.agp.components.Component

|---|---ohos.agp.components.ComponentContainer

|---|---|---ohos.agp.components.AdaptiveBoxLayout

public class AdaptiveBoxLayout
extends ComponentContainer
Provides methods for creating adaptive box layouts.

An adaptive box layout is automatically divided into rows and columns of boxes with the same width and possibly different heights. The width of the boxes depends on the layout width and the number of boxes in each row, which is specified by the layout policy. A new row starts only after the previous row is filled. Each box contains a child component. The height of each box is determined by the height of the child component it contains. The height of each row is determined by the highest box in this row. The width of the layout can only be set to MATCH_PARENT or a fixed value. The length, width, and alignment mode can be set for the components in the layout.

Since:

3

Nested Class Summary

展开

Modifier and Type

Class

Description

static class

AdaptiveBoxLayout.LayoutConfig

Defines layout parameters for child components in an AdaptiveBoxLayout instance, including their width, height, margins, and gravity.

展开

Nested classes/interfaces inherited from class ohos.agp.components.ComponentContainer

ComponentContainer.ArrangeListener

Field Summary

展开

Fields inherited from class ohos.agp.components.ComponentContainer

FOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener

Constructor Summary

展开

Constructor

Description

AdaptiveBoxLayout​(Context context)

Default constructor used to create a AdaptiveBoxLayout instance by using the default attribute set and style.

AdaptiveBoxLayout​(Context context, AttrSet attrSet)

A constructor used to create a AdaptiveBoxLayout instance by using specified attribute set and default style after the XML file is parsed.

AdaptiveBoxLayout​(Context context, AttrSet attrSet, String styleName)

A constructor used to create a AdaptiveBoxLayout instance by using specified attribute set and specified style after the XML file is parsed.

Method Summary

展开

Modifier and Type

Method

Description

void

addAdaptiveRule​(int minWidth, int maxWidth, int columns)

Adds an adaptive rule that dictates the number of boxes allowed in each row in a layout whose width falls within the specified range.

void

clearAdaptiveRules​()

Clears all adaptive rules.

ComponentContainer.LayoutConfig

createLayoutConfig​(Context context, AttrSet attrSet)

Creates layout parameters using the attribute set of a child component.

void

removeAdaptiveRule​(int minWidth, int maxWidth, int columns)

Removes a specified rule.

ComponentContainer.LayoutConfig

verifyLayoutConfig​(ComponentContainer.LayoutConfig config)

Verifies layout parameters based on the current layout type.

展开

Methods inherited from class 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

展开

Methods inherited from interface ohos.agp.components.ComponentParent

getComponentParent, postLayout

展开

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

AdaptiveBoxLayout

public AdaptiveBoxLayout​(Context context)

Default constructor used to create a AdaptiveBoxLayout instance by using the default attribute set and style.

Parameters:

展开

Parameter Name

Parameter Description

context

Indicates the application context.

AdaptiveBoxLayout

public AdaptiveBoxLayout​(Context context, AttrSet attrSet)

A constructor used to create a AdaptiveBoxLayout instance by using specified attribute set and default style after the XML file is parsed.

Parameters:

展开

Parameter Name

Parameter Description

context

Indicates the application context.

attrSet

Indicates the attribute set to be used.

AdaptiveBoxLayout

public AdaptiveBoxLayout​(Context context, AttrSet attrSet, String styleName)

A constructor used to create a AdaptiveBoxLayout instance by using specified attribute set and specified style after the XML file is parsed.

Parameters:

展开

Parameter Name

Parameter Description

context

Indicates the application context.

attrSet

Indicates the attribute set to be used.

styleName

Indicates the style name to use.

Method Detail

addAdaptiveRule

public void addAdaptiveRule​(int minWidth, int maxWidth, int columns)

Adds an adaptive rule that dictates the number of boxes allowed in each row in a layout whose width falls within the specified range.

If the width of a layout falls with the range defined by an adaptive rule, this rule applies. Otherwise, the default rule applies.

Parameters:

展开

Parameter Name

Parameter Description

minWidth

Indicates the minimum width for the rule to take effect.

maxWidth

Indicates the maximum width for the rule to take effect. This value must be greater than the value of minWidth. Otherwise, the rule cannot be added.

columns

Indicates the number of boxes allowed in each row. The value must be greater than 0. Otherwise, the rule cannot be added.

Throws:

展开

Throw Name

Throw Description

IllegalArgumentException

Throws this exception if the rule can't be added due to invalid parameters.

clearAdaptiveRules

public void clearAdaptiveRules​()

Clears all adaptive rules.

The default rule applies after all adaptive rules are cleared.

removeAdaptiveRule

public void removeAdaptiveRule​(int minWidth, int maxWidth, int columns)

Removes a specified rule.

Parameters:

展开

Parameter Name

Parameter Description

minWidth

Indicates the minimum width for the rule to take effect.

maxWidth

Indicates the maximum width for the rule to take effect.

columns

Indicates the number of columns allowed in each row.

Since:

4

verifyLayoutConfig

public ComponentContainer.LayoutConfig verifyLayoutConfig​(ComponentContainer.LayoutConfig config)

Description copied from class: ComponentContainer

Verifies layout parameters based on the current layout type.

Specified by:

verifyLayoutConfig in interface ComponentParent

Overrides:

verifyLayoutConfig in class ComponentContainer

Parameters:

展开

Parameter Name

Parameter Description

config

Indicates a group of layout parameters to be converted into a ComponentContainer instance.

Returns:

Returns the LayoutConfig instance, which represents the layout parameters.

createLayoutConfig

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

Description copied from class: ComponentContainer

Creates layout parameters using the attribute set of a child component.

Overrides:

createLayoutConfig in class ComponentContainer

Parameters:

展开

Parameter Name

Parameter Description

context

Indicates the application context.

attrSet

Indicates the attribute set.

Returns:

Returns the layout parameters created.

搜索
请输入您想要搜索的关键词