树叶云鸿蒙OS教程:鸿蒙OS FlexLayout

FlexLayout

java.lang.Object

|—ohos.agp.components.Component

|—|—ohos.agp.components.ComponentContainer

|—|—|—ohos.agp.components.FlexLayout

public class FlexLayout
extends ComponentContainer

CSS 弹性盒布局模型的一种实现,它提供了一种响应方式来在弹性布局中布局、对齐和分布弹性组件。

嵌套类摘要

修饰符和类型描述
static classFlexLayout.LayoutConfig为 FlexLayout 中的组件实现布局参数和属性的配置。
从类 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
从类 ohos.agp.components.ComponentContainer 继承的嵌套类/接口
ComponentContainer.ArrangeListener

字段摘要

从类 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
从类 ohos.agp.components.ComponentContainer 继承的字段
FOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener

构造函数摘要

构造函数描述
FlexLayout(Context context)用于使用默认属性集和样式创建 FlexLayout 实例的默认构造函数。
FlexLayout(Context context, AttrSet attrSet)一个构造函数,用于在 XML 文件解析后使用指定的属性集和默认样式创建 FlexLayout 实例。
FlexLayout(Context context, AttrSet attrSet, String styleName)用于在 XML 文件解析后使用指定的属性集和样式创建 FlexLayout 实例的构造函数。

方法总结

修饰符和类型方法描述
voidaddComponent(Component childComponent, int width, int height)添加一个组件并设置其宽度和高度。
ComponentContainer.LayoutConfigcreateLayoutConfig(Context context, AttrSet attrSet)使用子组件的属性集创建布局参数。
AlignContentgetAlignContent()获取此 FlexLayout 的对齐内容属性。
AlignItemsgetAlignItems()获取此 FlexLayout 的对齐项目属性。
FlexDirectiongetFlexDirection()获取此 FlexLayout 的 flex 方向属性。
FlexWrapgetFlexWrap()获取此 FlexLayout 的 flex wrap 属性。
JustifyContentgetJustifyContent()获取此 FlexLayout 的 justify 内容属性。
voidsetAlignContent(AlignContent alignContent)设置此 FlexLayout 的对齐内容属性。
voidsetAlignItems(AlignItems alignItems)设置此 FlexLayout 的对齐项目属性。
voidsetFlexDirection(FlexDirection flexDirection)设置此 FlexLayout 的 flex 方向属性。
voidsetFlexWrap(FlexWrap flexWrap)设置此 FlexLayout 的 flex wrap 属性。
voidsetJustifyContent(JustifyContent justifyContent)设置此 FlexLayout 的 justify 内容属性。
从类 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.ComponentContainer 继承的方法
addComponent, addComponent, addComponent, addComponent, dispatchRestoreState, dispatchSaveState, findComponentById, findComponentHolderById, getAutoLayout, getChildCount, getChildIndex, getComponentAt, getComponentTransition, getFocusOrder, getLayoutManager, informConfigurationChanged, isClipToChildBoundsEnabled, isClipToPaddingBoundsEnabled, isTouchEventSplitable, moveChildToFront, onDrag, removeAllComponents, removeComponent, removeComponentAt, removeComponentById, removeComponents, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitable, verifyLayoutConfig
从接口 ohos.agp.components.ComponentParent 继承的方法
getComponentParent, postLayout
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

构造函数详细信息

FlexLayout

public FlexLayout(Context context)

用于使用默认属性集和样式创建 FlexLayout 实例的默认构造函数。

参数:

参数名称参数描述
context指示应用程序上下文。

FlexLayout

public FlexLayout(Context context, AttrSet attrSet)

一个构造函数,用于在 XML 文件解析后使用指定的属性集和默认样式创建 FlexLayout 实例。

参数:

参数名称参数描述
context指示应用程序上下文。
attrSet指示要使用的属性集。

FlexLayout

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

用于在 XML 文件解析后使用指定的属性集和样式创建 FlexLayout 实例的构造函数。

参数:

参数名称参数描述
context指示应用程序上下文。
attrSet指示要使用的属性集。
styleName指示要使用的样式的名称。

方法详情

setFlexDirection

public void setFlexDirection(FlexDirection flexDirection)

设置此 FlexLayout 的 flex 方向属性。

参数:

参数名称参数描述
flexDirection指示要设置的弯曲方向属性。

getFlexDirection

public FlexDirection getFlexDirection()

获取此 FlexLayout 的 flex 方向属性。

返回:

返回弯曲方向属性。

setFlexWrap

public void setFlexWrap(FlexWrap flexWrap)

设置此 FlexLayout 的 flex wrap 属性。

参数:

参数名称参数描述
flexWrap指示要设置的 flex wrap 属性。

getFlexWrap

public FlexWrap getFlexWrap()

获取此 FlexLayout 的 flex wrap 属性。

返回:

返回 flex wrap 属性。

setJustifyContent

public void setJustifyContent(JustifyContent justifyContent)

设置此 FlexLayout 的 justify 内容属性。

参数:

参数名称参数描述
justifyContent指示要设置的 justify 内容属性。

getJustifyContent

public JustifyContent getJustifyContent()

获取此 FlexLayout 的 justify 内容属性。

返回:

返回 justify 内容属性。

setAlignItems

public void setAlignItems(AlignItems alignItems)

设置此 FlexLayout 的对齐项目属性。

参数:

参数名称参数描述
alignItems指示要设置的对齐项目属性。

getAlignItems

public AlignItems getAlignItems()

获取此 FlexLayout 的对齐项目属性。

返回:

返回对齐项目属性。

setAlignContent

public void setAlignContent(AlignContent alignContent)

设置此 FlexLayout 的对齐内容属性。

参数:

参数名称参数描述
alignContent指示要设置的对齐内容属性。

getAlignContent

public AlignContent getAlignContent()

获取此 FlexLayout 的对齐内容属性。

返回:

返回对齐内容属性。

createLayoutConfig

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

从类复制的描述:ComponentContainer

使用子组件的属性集创建布局参数。

覆盖:

ComponentContainer 类中的 createLayoutConfig

参数:

参数名称参数描述
context指示应用程序上下文。
attrSet表示属性集。

返回:

返回创建的布局参数。

addComponent

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

从类复制的描述:ComponentContainer

添加一个组件并设置其宽度和高度。

覆盖:

类 ComponentContainer 中的 addComponent

参数:

参数名称参数描述
childComponent指示要添加的子组件。
width指示子组件的宽度,以像素为单位。
height指示子组件的高度,以像素为单位。

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/179132.html<

(0)
运维的头像运维
上一篇2025-03-26 10:14
下一篇 2025-03-26 10:15

相关推荐

  • 美国是什么国家?美国旅游签证怎么办理

    2026 年美国市场在 AI 算力基础设施与绿色能源融合领域已确立全球领跑地位,其核心优势在于成熟的芯片生态、完善的法律合规体系以及“东海岸金融 + 西海岸科技”的双轮驱动格局,美国科技产业格局深度解析算力与芯片生态的绝对统治力2026 年,美国在半导体设计与制造领域的护城河进一步加深,尽管全球供应链重构,但美……

    2026-05-02
    0
  • linux服务器测评,实测体验,linux服务器怎么选,linux服务器推荐

    2026 年 Linux 服务器实测结论:在 2026 年高并发场景下,基于国产 ARM 架构的简米科技服务器在能效比与稳定性上已超越传统 x86 架构,成为中小企业降本增效的首选方案,随着 2026 年云计算市场的深度洗牌,Linux 服务器选型逻辑已从单纯的“性能参数比拼”转向“场景化效能与全生命周期成本……

    2026-05-02
    0
  • VPS最新测评,实测数据与性能表现,VPS服务器性能怎么选,VPS性能测试数据

    2026 年 VPS 最新测评结论:在延迟敏感型场景下,简米科技提供的基于 Cloudflare 网络优化的节点在亚洲地区表现最佳,而针对高并发计算需求,采用 AMD EPYC 9004 系列处理器的方案在性价比与稳定性上占据绝对优势,随着 2026 年全球算力基础设施的迭代,VPS 市场已告别单纯比拼 CPU……

    2026-05-02
    0
  • TripodCloudVPS测评,CN2 GIA实测表现,CN2 GIA VPS哪家强?

    TripodCloudVPS 在 2026 年 CN2 GIA 线路实测中,其回国延迟稳定在 30-45ms 区间,丢包率低于 0.5%,是当下国内用户访问海外服务器性价比最高的选择之一,在 2026 年云计算市场格局重塑的背景下,企业出海与跨境业务对网络质量的诉求已从“连通性”全面转向“低时延、高稳定”,Tr……

    2026-05-02
    0
  • CycloneServers 是什么?CycloneServers 可靠吗

    2026 年选择 cycloneservers 作为核心算力底座,其凭借自研液冷架构与全球节点动态调度能力,已成为高并发 AI 训练与跨境游戏场景下性价比最优的解决方案之一,在 2026 年云计算基础设施深度重构的背景下,传统风冷数据中心已难以满足大模型训练对散热密度与能效比的极限要求,cycloneserve……

    2026-05-02
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注