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

SlideDrawer

java.lang.Object

|—ohos.agp.components.Component

|—|—ohos.agp.components.ComponentContainer

|—|—|—ohos.agp.components.SlideDrawer

public class SlideDrawer
extends ComponentContainer

提供 SlideDrawer 项。

此类允许显示主要组件,同时隐藏与不同方向(开始、顶部、结束和底部)相关的四个可选组件的集合。 要显示可选组件,最终用户需要从相应的方向滑动。

Since:

5

嵌套类摘要

修饰符和类型描述
static classSlideDrawer.DisplayMode枚举要显示的可选组件的模式。
static classSlideDrawer.DrawerState枚举 SlideDrawer 的可能状态。
static classSlideDrawer.LayoutConfig配置 SlideDrawer 的布局参数,包括宽度、高度、边距、SlideDirection 和 DisplayMode。
static classSlideDrawer.SlideDirection枚举可选组件相对于主组件的方向。
static interfaceSlideDrawer.SlideDisable允许实时禁用幻灯片。
static interfaceSlideDrawer.SlideListener监听 SlideDrawer 状态变化。
从类 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

字段摘要

修饰符和类型字段描述
static SlideDrawer.DisplayModeDEFAULT_DISPLAY_MODE指示 DisplayMode 的默认值。
static floatDEFAULT_OPEN_THRESHOLD指示可滑动打开可选组件的默认百分比值。
从类 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

构造函数摘要

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

方法总结

修饰符和类型方法描述
voidaddSlideDisable(SlideDrawer.SlideDisable callback)添加允许实时禁用幻灯片事件的回调。
voidaddSlideListener(SlideDrawer.SlideListener listener)添加幻灯片侦听器。
booleanclose()如果当前状态为 DrawerState#OPEN,则关闭 SlideDrawer。
booleanclose(SlideDrawer.SlideDirection direction)如果当前状态为 DrawerState#OPEN 且方向参数等于 getSlideDirection() 返回的值,则在某个方向关闭 SlideDrawer。
booleancloseSmoothly()如果 SlideDrawer 当前状态为 DrawerState#OPEN,则平滑关闭 SlideDrawer。
booleancloseSmoothly(int interval)如果 SlideDrawer 当前状态为 DrawerState#OPEN,则平滑关闭 SlideDrawer。
booleancloseSmoothly(SlideDrawer.SlideDirection direction)如果当前状态为 DrawerState#OPEN 且方向参数等于 getSlideDirection() 返回的值,则在某个方向平滑关闭 SlideDrawer。
booleancloseSmoothly(SlideDrawer.SlideDirection direction, int interval)如果当前状态为 DrawerState#OPEN 且方向参数等于 getSlideDirection() 返回的值,则在某个方向平滑关闭 SlideDrawer。
ComponentContainer.LayoutConfigcreateLayoutConfig(Context context, AttrSet attrSet)使用子组件的属性集创建布局参数。
SlideDrawer.DisplayMode[]getDisplayMode()获取所有方向的可选组件的显示模式。
SlideDrawer.DisplayModegetDisplayMode(SlideDrawer.SlideDirection direction)获取可选组件在某个方向上的显示方式。
floatgetOpenThreshold()获取可以滑动打开可选组件的百分比值。
SlideDrawer.SlideDirectiongetSlideDirection()获取当前 SlideDrawer 方向。
intgetSlideDistance(SlideDrawer.SlideDirection direction)获取某个方向的最大滑动距离。
floatgetSlideDistanceRatio()获取当前从起始位置的滑动百分比。
SlideDrawer.DrawerStategetSlideState()获取当前 SlideDrawer 状态。
booleanhasSlideDisables()检查是否有任何禁用回调存储在 SlideDrawer 中。
booleanhasSlideListeners()检查是否有任何侦听器存储在 SlideDrawer 中。
booleanisSlideEnabled()检查是否启用了滑动手势。
booleanisTouchForClose()检查 SlideDrawer 是否可以通过触摸关闭。
booleanopen()如果 SlideDrawer 包含仅用于单向的可选组件,则打开 SlideDrawer)。
booleanopen(SlideDrawer.SlideDirection direction)如果 SlideDrawer 当前状态为 DrawerState#CLOSE,则朝某个方向打开 SlideDrawer。
booleanopenSmoothly()如果 SlideDrawer 包含仅用于单向的可选组件,则平滑打开 SlideDrawer)。
booleanopenSmoothly(int interval)如果 SlideDrawer 包含仅用于单向的可选组件,则平滑打开 SlideDrawer)。
booleanopenSmoothly(SlideDrawer.SlideDirection direction)如果 SlideDrawer 当前状态为 DrawerState#CLOSE,则在某个方向平滑打开 SlideDrawer。
booleanopenSmoothly(SlideDrawer.SlideDirection direction, int interval)如果 SlideDrawer 当前状态为 DrawerState#CLOSE,则在某个方向平滑打开 SlideDrawer。
voidremoveAllSlideDisables()删除所有允许实时禁用幻灯片事件的回调。
voidremoveAllSlideListeners()删除所有幻灯片侦听器。
voidremoveComponents(int start, int count)从组件列表中的指定位置移除所有组件。
voidremoveSlideDisable(SlideDrawer.SlideDisable callback)删除允许实时禁用幻灯片事件的回调。
voidremoveSlideListener(SlideDrawer.SlideListener listener)删除幻灯片侦听器。
voidsetDisplayMode(SlideDrawer.DisplayMode mode)设置所有可选组件的显示模式。
voidsetDisplayMode(SlideDrawer.DisplayMode startMode, SlideDrawer.DisplayMode topMode, SlideDrawer.DisplayMode endMode, SlideDrawer.DisplayMode bottomMode)为所有方向设置不同的显示模式。
voidsetDisplayMode(SlideDrawer.DisplayMode mode, SlideDrawer.SlideDirection direction)设置可选组件从某个方向的显示模式。
voidsetMaximumSlideDistance(int max)设置最大滑动距离。
voidsetOpenThreshold(float percent)设置可以滑动打开可选组件的百分比值。
voidsetSlideEnabled(boolean isEnabled)设置 SlideDrawer 是否可以被用户滑动。
voidsetTouchForClose(boolean isEnabled)设置 SlideDrawer 是否可以通过触摸关闭。
booleantoggle()在 DrawerState#OPEN 和 DrawerState#CLOSE 之间切换 SlideDrawer 状态。
booleantoggle(SlideDrawer.SlideDirection direction)在特定方向上切换 DrawerState#OPEN 和 DrawerState#CLOSE 之间的 SlideDrawer 状态。
booleantoggleSmoothly()在 DrawerState#OPEN 和 DrawerState#CLOSE 之间平滑切换 SlideDrawer 状态。
booleantoggleSmoothly(int interval)在 DrawerState#OPEN 和 DrawerState#CLOSE 之间平滑切换 SlideDrawer 状态。
booleantoggleSmoothly(SlideDrawer.SlideDirection direction)DrawerState#OPEN 和 DrawerState#CLOSE 之间的 SlideDrawer 状态在某个方向上平滑切换。
booleantoggleSmoothly(SlideDrawer.SlideDirection direction, int interval)DrawerState#OPEN 和 DrawerState#CLOSE 之间的 SlideDrawer 状态在某个方向上平滑切换。
ComponentContainer.LayoutConfigverifyLayoutConfig(ComponentContainer.LayoutConfig config)根据当前布局类型验证布局参数。
从类 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, addComponent, dispatchRestoreState, dispatchSaveState, findComponentById, findComponentHolderById, getAutoLayout, getChildCount, getChildIndex, getComponentAt, getComponentTransition, getFocusOrder, getLayoutManager, informConfigurationChanged, isClipToChildBoundsEnabled, isClipToPaddingBoundsEnabled, isTouchEventSplitable, moveChildToFront, onDrag, removeAllComponents, removeComponent, removeComponentAt, removeComponentById, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitable
从接口 ohos.agp.components.ComponentParent 继承的方法
getComponentParent, postLayout
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

字段详细信息

DEFAULT_DISPLAY_MODE

public static final SlideDrawer.DisplayMode DEFAULT_DISPLAY_MODE

指示 DisplayMode 的默认值。

Since:

5

DEFAULT_OPEN_THRESHOLD

public static final float DEFAULT_OPEN_THRESHOLD

指示可滑动打开可选组件的默认百分比值。

Since:

5

构造函数详细信息

SlideDrawer

public SlideDrawer(Context context)

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

参数:

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

Since:

5

SlideDrawer

public SlideDrawer(Context context, AttrSet attrSet)

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

参数:

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

Since:

5

SlideDrawer

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

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

参数:

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

Since:

5

方法详情

addSlideListener

public void addSlideListener(SlideDrawer.SlideListener listener)

添加幻灯片侦听器。

参数:

参数名称参数描述
listener表示 SlideListener 对象,不能为空。

Throws:

Throw名称Throw描述
IllegalArgumentException如果侦听器值为 null,则引发此异常。

Since:

5

removeSlideListener

public void removeSlideListener(SlideDrawer.SlideListener listener)

删除幻灯片侦听器。

您可以使用 removeAllSlideListeners() 删除所有侦听器。

参数:

参数名称参数描述
listener表示 SlideListener 对象,不能为空。

Throws:

Throw名称Throw描述
IllegalArgumentException如果侦听器值为 null,则引发此异常。

Since:

5

removeAllSlideListeners

public void removeAllSlideListeners()

删除所有幻灯片侦听器。

Since:

5

hasSlideListeners

public boolean hasSlideListeners()

检查是否有任何侦听器存储在 SlideDrawer 中。

返回:

如果 SlideDrawer 包含任何侦听器,则返回 true; 否则返回 false。

Since:

5

addSlideDisable

public void addSlideDisable(SlideDrawer.SlideDisable callback)

添加允许实时禁用幻灯片事件的回调。

参数:

参数名称参数描述
callback表示要添加的回调。 该值不能为空。

Throws:

Throw名称Throw描述
IllegalArgumentException如果回调值为 null,则引发此异常。

Since:

5

removeSlideDisable

public void removeSlideDisable(SlideDrawer.SlideDisable callback)

删除允许实时禁用幻灯片事件的回调。

您可以使用 removeAllSlideDisables() 删除所有此类回调。

参数:

参数名称参数描述
callback指示要删除的回调。 该值不能为空。

Throws:

Throw名称Throw描述
IllegalArgumentException如果回调值为 null,则引发此异常。

Since:

5

removeAllSlideDisables

public void removeAllSlideDisables()

删除所有允许实时禁用幻灯片事件的回调。

Since:

5

hasSlideDisables

public boolean hasSlideDisables()

检查是否有任何禁用回调存储在 SlideDrawer 中。

返回:

如果 SlideDrawer 包含任何禁用回调,则返回 true; 否则返回 false。

Since:

5

setTouchForClose

public void setTouchForClose(boolean isEnabled)

设置 SlideDrawer 是否可以通过触摸关闭。

参数:

参数名称参数描述
isEnabled指定 SlideDrawer 是否可以通过触摸关闭。

Since:

5

isTouchForClose

public boolean isTouchForClose()

检查 SlideDrawer 是否可以通过触摸关闭。

返回:

如果 SlideDrawer 可以通过触摸关闭,则返回 true; 否则返回 false。

Since:

5

setSlideEnabled

public void setSlideEnabled(boolean isEnabled)

设置 SlideDrawer 是否可以被用户滑动。

参数:

参数名称参数描述
isEnabled指定是否启用滑动手势。

Since:

5

isSlideEnabled

public boolean isSlideEnabled()

检查是否启用了滑动手势。

返回:

如果启用了滑动手势,则返回 true; 否则返回 false。

Since:

5

setOpenThreshold

public void setOpenThreshold(float percent)

设置可以滑动打开可选组件的百分比值。

默认百分比值为 DEFAULT_OPEN_THRESHOLD。

参数:

参数名称参数描述
percent表示百分比值。

Throws:

Throw名称Throw描述
IllegalArgumentException如果百分比值小于 0.0f 或大于 1.0f,则引发此异常。

Since:

5

getOpenThreshold

public float getOpenThreshold()

获取可以滑动打开可选组件的百分比值。

默认百分比值为 DEFAULT_OPEN_THRESHOLD。

返回:

返回百分比值。

Since:

5

getSlideDistanceRatio

public float getSlideDistanceRatio()

获取当前从起始位置的滑动百分比。

返回:

返回滑动百分比。

Since:

5

setMaximumSlideDistance

public void setMaximumSlideDistance(int max)

设置最大滑动距离。

参数:

参数名称参数描述
max表示最大滑动距离。

Throws:

Throw名称Throw描述
IllegalArgumentException如果参数值小于 0,则抛出此异常。

Since:

5

getSlideDistance

public int getSlideDistance(SlideDrawer.SlideDirection direction)

获取某个方向的最大滑动距离。

参数:

参数名称参数描述
direction指示方向。

返回:

返回最大滑动距离。

Throws:

Throw名称Throw描述
IllegalArgumentException如果方向值为空,则引发此异常。

Since:

5

getSlideState

public SlideDrawer.DrawerState getSlideState()

获取当前 SlideDrawer 状态。 状态值可以是 DrawerState#OPEN、DrawerState#MIDDLE 或 DrawerState#CLOSE。

返回:

返回当前状态。

Since:

5

getSlideDirection

public SlideDrawer.SlideDirection getSlideDirection()

获取当前 SlideDrawer 方向。 该值可以是 SlideDirection#START、SlideDirection#TOP、SlideDirection#END 或 SlideDirection#BOTTOM。 如果当前 SlideDrawer 状态不是 DrawerState#OPEN,则返回值为 null。

返回:

返回当前的 SlideDirection 或 null。

Since:

5

setDisplayMode

public void setDisplayMode(SlideDrawer.DisplayMode mode)

设置所有可选组件的显示模式。 模式可以是 DisplayMode#NO_ANIMATION 或 DisplayMode#WITH_ANIMATION。

默认模式为 DEFAULT_DISPLAY_MODE。

如果您希望仅为指定方向设置显示模式,可以使用 setDisplayMode(ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.SlideDirection) 方法。

您可以使用 setDisplayMode(ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.DisplayMode) 方法设置不同的 一次调用中所有四个方向的值。

不建议同时使用 DisplayMode#NO_ANIMATION 和 padding。

参数:

参数名称参数描述
mode表示显示模式。

Throws:

Throw名称Throw描述
IllegalArgumentException如果模式值为 null,则引发此异常。

Since:

5

setDisplayMode

public void setDisplayMode(SlideDrawer.DisplayMode mode, SlideDrawer.SlideDirection direction)

设置可选组件从某个方向的显示模式。 模式可以是 DisplayMode#NO_ANIMATION 或 DisplayMode#WITH_ANIMATION。

默认模式为 DEFAULT_DISPLAY_MODE。

您可以使用 setDisplayMode(ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.DisplayMode) 方法设置不同的 一次调用中所有四个方向的值。

您可以使用 setDisplayMode(ohos.agp.components.SlideDrawer.DisplayMode) 方法为所有方向设置指定的显示模式。

不建议同时使用 DisplayMode#NO_ANIMATION 和 padding。

参数:

参数名称参数描述
mode表示显示模式。
direction指示方向。

Throws:

Throw名称Throw描述
IllegalArgumentException如果方向或模式值为 null,则引发此异常。

Since:

5

setDisplayMode

public void setDisplayMode(SlideDrawer.DisplayMode startMode, SlideDrawer.DisplayMode topMode, SlideDrawer.DisplayMode endMode, SlideDrawer.DisplayMode bottomMode)

为所有方向设置不同的显示模式。 模式可以是 DisplayMode#NO_ANIMATION 或 DisplayMode#WITH_ANIMATION。

默认模式为 DEFAULT_DISPLAY_MODE。

如果您希望仅为指定方向设置显示模式,可以使用 setDisplayMode(ohos.agp.components.SlideDrawer.DisplayMode,ohos.agp.components.SlideDrawer.SlideDirection) 方法。

您可以使用 setDisplayMode(ohos.agp.components.SlideDrawer.DisplayMode) 方法为所有方向设置指定的显示模式。

不建议同时使用 DisplayMode#NO_ANIMATION 和 padding。

参数:

参数名称参数描述
startMode指示与 SlideDirection#START 方向相关的显示模式。
topMode指示与 SlideDirection#TOP 方向相关的显示模式。
endMode指示与 SlideDirection#END 方向相关的显示模式。
bottomMode指示与 SlideDirection#BOTTOM 方向相关的显示模式。

Throws:

Throw名称Throw描述
IllegalArgumentException如果任何模式为空,则引发此异常。

Since:

5

getDisplayMode

public SlideDrawer.DisplayMode getDisplayMode(SlideDrawer.SlideDirection direction)

获取可选组件在某个方向上的显示方式。

默认模式为 DEFAULT_DISPLAY_MODE。

您可以使用 getDisplayMode() 方法一次调用获取所有方向的显示模式。

参数:

参数名称参数描述
direction指示方向。

返回:

返回显示模式。

Throws:

Throw名称Throw描述
IllegalArgumentException如果方向值为空,则引发此异常。

Since:

5

getDisplayMode

public SlideDrawer.DisplayMode[] getDisplayMode()

获取所有方向的可选组件的显示模式。

默认模式为 DEFAULT_DISPLAY_MODE。

您可以使用getDisplayMode(ohos.agp.components.SlideDrawer.SlideDirection) 方法获取某个方向的显示模式。

返回:

返回模式数组,其中: 第一个元素(索引 0)- SlideDirection#START 方向的模式; 第二个元素(索引 1) – SlideDirection#TOP 方向的模式; 第三个元素(索引 2)- SlideDirection#BOTTOM 方向的模式; 第四个元素(索引 3)- SlideDirection#END 方向的模式。

Since:

5

open

public boolean open()

如果 SlideDrawer 包含仅用于单向的可选组件,则打开 SlideDrawer)。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

open

public boolean open(SlideDrawer.SlideDirection direction)

如果 SlideDrawer 当前状态为 DrawerState#CLOSE,则朝某个方向打开 SlideDrawer。 如果 SlideDrawer 包含仅可以从一个方向与幻灯片一起显示的可选组件,则可以传递 null 作为方向以打开 SlideDrawer。

参数:

参数名称参数描述
direction方向,可以设置为null。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

openSmoothly

public boolean openSmoothly()

如果 SlideDrawer 包含仅用于单向的可选组件,则平滑打开 SlideDrawer)。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

openSmoothly

public boolean openSmoothly(SlideDrawer.SlideDirection direction)

如果 SlideDrawer 当前状态为 DrawerState#CLOSE,则在某个方向平滑打开 SlideDrawer。 如果 SlideDrawer 包含仅可以从一个方向与幻灯片一起显示的可选组件,则可以传递 null 作为方向以打开 SlideDrawer。

参数:

参数名称参数描述
direction方向,可以设置为null。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

openSmoothly

public boolean openSmoothly(int interval)

如果 SlideDrawer 包含仅用于单向的可选组件,则平滑打开 SlideDrawer)。

参数:

参数名称参数描述
interval滚动的间隔值,以毫秒为单位。

返回:

如果操作成功,则返回 true; 否则返回 false。

Throws:

Throw名称Throw描述
IllegalArgumentException如果间隔值小于 0,则抛出此异常。

Since:

5

openSmoothly

public boolean openSmoothly(SlideDrawer.SlideDirection direction, int interval)

如果 SlideDrawer 当前状态为 DrawerState#CLOSE,则在某个方向平滑打开 SlideDrawer。 如果 SlideDrawer 包含仅可以从一个方向与幻灯片一起显示的可选组件,则可以传递 null 作为方向以打开 SlideDrawer。

参数:

参数名称参数描述
direction方向,可以设置为null。
interval滚动的间隔值,以毫秒为单位。

返回:

如果操作成功,则返回 true; 否则返回 false。

Throws:

Throw名称Throw描述
IllegalArgumentException如果间隔值小于 0,则抛出此异常。

Since:

5

close

public boolean close()

如果当前状态为 DrawerState#OPEN,则关闭 SlideDrawer。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

close

public boolean close(SlideDrawer.SlideDirection direction)

如果当前状态为 DrawerState#OPEN 且方向参数等于 getSlideDirection() 返回的值,则在某个方向关闭 SlideDrawer。 无论如何,您都可以传递 null 作为关闭 SlideDrawer 的方向。

参数:

参数名称参数描述
direction方向,可以设置为null。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

closeSmoothly

public boolean closeSmoothly()

如果 SlideDrawer 当前状态为 DrawerState#OPEN,则平滑关闭 SlideDrawer。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

closeSmoothly

public boolean closeSmoothly(SlideDrawer.SlideDirection direction)

如果当前状态为 DrawerState#OPEN 且方向参数等于 getSlideDirection() 返回的值,则在某个方向平滑关闭 SlideDrawer。 无论如何,您都可以传递 null 作为关闭 SlideDrawer 的方向。

参数:

参数名称参数描述
direction方向,可以设置为null。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

closeSmoothly

public boolean closeSmoothly(int interval)

如果 SlideDrawer 当前状态为 DrawerState#OPEN,则平滑关闭 SlideDrawer。

参数:

参数名称参数描述
interval滚动的间隔值,以毫秒为单位。

返回:

如果操作成功,则返回 true; 否则返回 false。

Throws:

Throw名称Throw描述
IllegalArgumentException如果间隔值小于 0,则抛出此异常。

Since:

5

closeSmoothly

public boolean closeSmoothly(SlideDrawer.SlideDirection direction, int interval)

如果当前状态为 DrawerState#OPEN 且方向参数等于 getSlideDirection() 返回的值,则在某个方向平滑关闭 SlideDrawer。 无论如何,您都可以传递 null 作为关闭 SlideDrawer 的方向。

参数:

参数名称参数描述
direction方向,可以设置为null。
interval滚动的间隔值,以毫秒为单位。

返回:

如果操作成功,则返回 true; 否则返回 false。

Throws:

Throw名称Throw描述
IllegalArgumentException如果间隔值小于 0,则抛出此异常。

Since:

5

toggle

public boolean toggle()

在 DrawerState#OPEN 和 DrawerState#CLOSE 之间切换 SlideDrawer 状态。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

toggle

public boolean toggle(SlideDrawer.SlideDirection direction)

在特定方向上切换 DrawerState#OPEN 和 DrawerState#CLOSE 之间的 SlideDrawer 状态。 如果 SlideDrawer 包含仅可以从一个方向与幻灯片一起显示的可选组件,则可以传递 null 作为方向以切换 SlideDrawer 状态。

参数:

参数名称参数描述
direction方向,可以设置为null。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

toggleSmoothly

public boolean toggleSmoothly()

在 DrawerState#OPEN 和 DrawerState#CLOSE 之间平滑切换 SlideDrawer 状态。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

toggleSmoothly

public boolean toggleSmoothly(SlideDrawer.SlideDirection direction)

DrawerState#OPEN 和 DrawerState#CLOSE 之间的 SlideDrawer 状态在某个方向上平滑切换。 如果 SlideDrawer 包含仅可以从一个方向与幻灯片一起显示的可选组件,则可以传递 null 作为方向以切换 SlideDrawer 状态。

参数:

参数名称参数描述
direction方向,可以设置为null。

返回:

如果操作成功,则返回 true; 否则返回 false。

Since:

5

toggleSmoothly

public boolean toggleSmoothly(int interval)

在 DrawerState#OPEN 和 DrawerState#CLOSE 之间平滑切换 SlideDrawer 状态。

参数:

参数名称参数描述
interval滚动的间隔值,以毫秒为单位。

返回:

如果操作成功,则返回 true; 否则返回 false。

Throws:

Throw名称Throw描述
IllegalArgumentException如果间隔值小于 0,则抛出此异常。

Since:

5

toggleSmoothly

public boolean toggleSmoothly(SlideDrawer.SlideDirection direction, int interval)

DrawerState#OPEN 和 DrawerState#CLOSE 之间的 SlideDrawer 状态在某个方向上平滑切换。 如果 SlideDrawer 包含仅可以从一个方向与幻灯片一起显示的可选组件,则可以传递 null 作为方向以切换 SlideDrawer 状态。

参数:

参数名称参数描述
direction方向,可以设置为null。
interval滚动的间隔值,以毫秒为单位。

返回:

如果操作成功,则返回 true; 否则返回 false。

Throws:

Throw名称Throw描述
IllegalArgumentException如果间隔值小于 0,则抛出此异常。

Since:

5

verifyLayoutConfig

public ComponentContainer.LayoutConfig verifyLayoutConfig(ComponentContainer.LayoutConfig config)

根据当前布局类型验证布局参数。

指定者:

接口 ComponentParent 中的 verifyLayoutConfig

覆盖:

ComponentContainer 类中的 verifyLayoutConfig

参数:

参数名称参数描述
config指示要转换为 ComponentContainer 实例的一组布局参数。

返回:

返回 LayoutConfig 实例,它表示布局参数。

createLayoutConfig

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

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

覆盖:

ComponentContainer 类中的 createLayoutConfig

参数:

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

返回:

返回创建的布局参数。

removeComponents

public void removeComponents(int start, int count)

从组件列表中的指定位置移除所有组件。

指定者:

接口 ComponentParent 中的 removeComponents

覆盖:

ComponentContainer 类中的 removeComponents

参数:

参数名称参数描述
start表示第一个移除的组件的位置索引。
count表示要移除的组件数量。

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

(0)
管理的头像管理
上一篇2025-03-15 20:21
下一篇 2025-03-15 20:22

相关推荐

  • 云服务器和云虚拟主机怎么选?云服务器和虚拟主机区别

    云服务器适合业务增长快、需弹性扩展的场景,而云虚拟主机适合预算有限、技术门槛低的小型静态网站或测试环境,二者核心区别在于资源独享性与运维复杂度,核心差异解析:从底层架构到使用体验很多人容易混淆这两者,觉得它们都是“买空间建站”,它们的底层逻辑完全不同,云服务器(ECS)就像是你租了一整栋别墅,水电网络独立,你想……

    2026-06-29
    0
  • 赣州智慧旅游招聘是真的吗?赣州旅游人才招聘信息

    中级岗位(3-5年经验)月薪范围通常在6000-10000元,这类岗位需要独立负责项目模块,如独立运营一个抖音账号,或维护一个景区小程序的功能迭代,具备成功案例的候选人议价能力较强,高级岗位(5年以上经验)月薪范围通常在10000-20000元,部分核心管理岗可达更高,这类人才需要具备战略规划能力,如制定整个景……

    2026-06-29
    0
  • 赣州智能物联网车位锁如何管理?智能车位锁管理系统多少钱

    赣州智能物联网车位锁管理的核心在于通过云端平台实现远程控锁、状态实时监控及自动计费,彻底解决传统车位“被占难管”与“找位难”的痛点,在赣州这样的城市,随着机动车保有量的持续增长,老旧小区、商业综合体以及私人固定车位的资源矛盾日益凸显,传统的机械地锁或简易遥控锁,不仅操作繁琐,更无法实现数据化管理,引入智能物联网……

    2026-06-29
    0
  • 赣州智能消防栓好用吗,智能消防栓多少钱一个

    赣州智能消防栓通过物联网技术实现实时监测与远程报警,能显著降低火灾响应时间并提升城市消防安全管理水平,是目前智慧城市建设中不可或缺的基础设施,赣州智能消防栓的核心价值与应用场景传统消防栓往往存在“看不见、摸不着、用不了”的痛点,在赣州这样地形复杂、老城区与新城区并存的区域,传统设施的管理难度极大,智能消防栓的出……

    2026-06-29
    0
  • 云服务器和物理机到底有啥区别?

    云服务器本质上是虚拟化资源池中的弹性实例,而传统物理服务器是独占的硬件实体,前者胜在弹性与运维便捷,后者强在物理隔离与性能稳定,具体选择取决于业务对成本、扩展性及安全合规的权衡,很多人初次接触服务器时,容易把“云服务器”和“传统物理服务器”混为一谈,觉得它们都是用来跑网站或存数据的盒子,这两者的底层逻辑完全不同……

    2026-06-29
    0

发表回复

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