鴻蒙OS PageSlider

2022-09-27 13:46 更新

PageSlider

java.lang.Object

|---ohos.agp.components.Component

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

|---|---|---ohos.agp.components.StackLayout

|---|---|---|---ohos.agp.components.PageSlider

  1. public class PageSlider
  2. extends StackLayout

一個(gè)布局管理器,允許用戶左右滑動(dòng)以及上下滑動(dòng)來(lái)翻頁(yè)。

作為一個(gè)容器類(lèi),它允許您添加其他組件。 必須設(shè)置 PageSliderProvider 以生成組件顯示的頁(yè)面。

Since:

3

嵌套類(lèi)摘要

修飾符和類(lèi)型 類(lèi) 描述
static interface PageSlider.PageChangedListener 提供一個(gè)監(jiān)聽(tīng)器來(lái)觀察頁(yè)面變化事件。
static class PageSlider.ReboundEffectParams 表示回彈效果參數(shù)。
從類(lèi) ohos.agp.components.Component 繼承的嵌套類(lèi)/接口
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
從類(lèi) ohos.agp.components.ComponentContainer 繼承的嵌套類(lèi)/接口
ComponentContainer.ArrangeListener
從類(lèi) ohos.agp.components.StackLayout 繼承的嵌套類(lèi)/接口
StackLayout.LayoutConfig

字段摘要

修飾符和類(lèi)型 字段 描述
static int DEFAULT_CACHED_PAGES_LIMIT 指示要在當(dāng)前頁(yè)面的任一側(cè)保留的最小頁(yè)面數(shù)。
static int INVALID_INDEX 表示無(wú)效的位置。
static float ROTATION_SENSITIVITY_DEFAULT 指示 PageSlider 響應(yīng)旋轉(zhuǎn)表冠事件的默認(rèn)旋轉(zhuǎn)靈敏度。
static float ROTATION_SENSITIVITY_HIGH 指示 PageSlider 響應(yīng)旋轉(zhuǎn)表冠事件的高旋轉(zhuǎn)靈敏度。
static float ROTATION_SENSITIVITY_LOW 指示 PageSlider 響應(yīng)旋轉(zhuǎn)表冠事件的低旋轉(zhuǎn)靈敏度。
static int SLIDING_STATE_DRAGGING 表示用戶當(dāng)前正在瀏覽頁(yè)面。
static int SLIDING_STATE_IDLE 表示當(dāng)前頁(yè)面完全在組件中,并且沒(méi)有動(dòng)畫(huà)正在進(jìn)行中。
static int SLIDING_STATE_SETTLING 表示頁(yè)面已滾動(dòng)到最終位置。
從類(lèi) 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
從類(lèi) ohos.agp.components.ComponentContainer 繼承的字段
FOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener

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

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

方法總結(jié)

修飾符和類(lèi)型 方法 描述
void addPageChangedListener(PageSlider.PageChangedListener listener) 注冊(cè)一個(gè)監(jiān)聽(tīng)頁(yè)面更改事件的監(jiān)聽(tīng)器。
int getCachedPagesLimit() 獲取當(dāng)前頁(yè)面兩側(cè)要保留的頁(yè)面數(shù)。
int getCurrentPage() 獲取選中的頁(yè)面。
int getCurrentSlidingState() 獲取當(dāng)前的滑動(dòng)狀態(tài)。
int getOrientation() 獲取頁(yè)面滑動(dòng)方向,可以是Component.HORIZONTAL或Component.VERTICAL。
int getPageMargin() 獲取頁(yè)面之間的邊距。
int getPageSwitchTime() 獲取頁(yè)面切換時(shí)間。
PageSliderProvider getProvider() 獲取為當(dāng)前頁(yè)面提供組件的分頁(yè)適配器。
boolean getReboundEffect() 獲取反彈效果的狀態(tài)。
PageSlider.ReboundEffectParams getReboundEffectParams() 獲取反彈參數(shù)作為 ReboundEffectParams 對(duì)象。
boolean getSlidingPossible() 獲取是否開(kāi)啟頁(yè)面滑動(dòng)。
boolean isCircularModeEnabled() 檢查是否為 PageSlider 啟用了循環(huán)模式。
void removePageChangedListener(PageSlider.PageChangedListener listener) 刪除以前注冊(cè)的頁(yè)面更改偵聽(tīng)器。
void setCircularModeEnabled(boolean enabled) 設(shè)置是否為 PageSlider 啟用循環(huán)模式。
void setCurrentPage(int itemPos) 設(shè)置選定的頁(yè)面。
void setCurrentPage(int itemPos, boolean smoothScroll) 設(shè)置當(dāng)前選擇的頁(yè)面。
void setOrientation(int orientation) 設(shè)置頁(yè)面滑動(dòng)方向,可以是Component.HORIZONTAL或Component.VERTICAL。
void setPageCacheSize(int cacheSize) 設(shè)置要保留在當(dāng)前頁(yè)面兩側(cè)的頁(yè)面數(shù)。
void setPageMargin(int margin) 設(shè)置頁(yè)面之間的邊距。
void setPageSwitchTime(int durationMs) 設(shè)置頁(yè)面切換時(shí)間。
void setProvider(PageSliderProvider provider) 設(shè)置為當(dāng)前頁(yè)面提供組件的尋呼機(jī)適配器。
void setReboundEffect(boolean enabled) 設(shè)置是否開(kāi)啟反彈效果。
void setReboundEffectParams(int overscrollPercent, float overscrollRate, int remainVisiblePercent) 配置回彈效果參數(shù)。
void setReboundEffectParams(PageSlider.ReboundEffectParams reboundEffectParams) 設(shè)置回彈效果參數(shù)。
void setSlidingPossible(boolean enable) 設(shè)置是否開(kāi)啟頁(yè)面滑動(dòng)。
從類(lèi) 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
從類(lèi) 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, removeComponents, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitable
從接口 ohos.agp.components.ComponentParent 繼承的方法
getComponentParent, postLayout
從類(lèi) java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
從類(lèi) ohos.agp.components.StackLayout 繼承的方法
createLayoutConfig, verifyLayoutConfig

字段詳細(xì)信息

DEFAULT_CACHED_PAGES_LIMIT

public static final int DEFAULT_CACHED_PAGES_LIMIT

指示要在當(dāng)前頁(yè)面的任一側(cè)保留的最小頁(yè)面數(shù)。 默認(rèn)值為 1。

INVALID_INDEX

public static final int INVALID_INDEX

表示無(wú)效的位置。 有效位置的數(shù)量比當(dāng)前適配器中的項(xiàng)目總數(shù)少 0 到 1。

ROTATION_SENSITIVITY_DEFAULT

public static final float ROTATION_SENSITIVITY_DEFAULT

指示 PageSlider 響應(yīng)旋轉(zhuǎn)表冠事件的默認(rèn)旋轉(zhuǎn)靈敏度。 您可以使用 Component.setRotationSensitivity(float) 進(jìn)行設(shè)置。

ROTATION_SENSITIVITY_HIGH

public static final float ROTATION_SENSITIVITY_HIGH

指示 PageSlider 響應(yīng)旋轉(zhuǎn)表冠事件的高旋轉(zhuǎn)靈敏度。 您可以使用 Component.setRotationSensitivity(float) 進(jìn)行設(shè)置。

ROTATION_SENSITIVITY_LOW

public static final float ROTATION_SENSITIVITY_LOW

指示 PageSlider 響應(yīng)旋轉(zhuǎn)表冠事件的低旋轉(zhuǎn)靈敏度。 您可以使用 Component.setRotationSensitivity(float) 進(jìn)行設(shè)置。

SLIDING_STATE_DRAGGING

public static final int SLIDING_STATE_DRAGGING

表示用戶當(dāng)前正在瀏覽頁(yè)面。

SLIDING_STATE_IDLE

public static final int SLIDING_STATE_IDLE

表示當(dāng)前頁(yè)面完全在組件中,并且沒(méi)有動(dòng)畫(huà)正在進(jìn)行中。

SLIDING_STATE_SETTLING

public static final int SLIDING_STATE_SETTLING

表示頁(yè)面已滾動(dòng)到最終位置。

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

PageSlider

public PageSlider(Context context)

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

參數(shù):

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

PageSlider

public PageSlider(Context context, AttrSet attrSet)

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

參數(shù):

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

PageSlider

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

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

參數(shù):

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

方法詳情

setProvider

public void setProvider(PageSliderProvider provider)

設(shè)置為當(dāng)前頁(yè)面提供組件的尋呼機(jī)適配器。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
provider 指示尋呼機(jī)適配器。

getProvider

public PageSliderProvider getProvider()

獲取為當(dāng)前頁(yè)面提供組件的分頁(yè)適配器。

返回:

如果有,則返回分配的尋呼適配器; 否則返回 null。

getCurrentPage

public int getCurrentPage()

獲取選中的頁(yè)面。

返回:

返回所選頁(yè)面底部的頁(yè)面索引; 如果沒(méi)有分配尋呼機(jī)適配器,則返回 INVALID_INDEX。

addPageChangedListener

public void addPageChangedListener(PageSlider.PageChangedListener listener)

注冊(cè)一個(gè)監(jiān)聽(tīng)頁(yè)面更改事件的監(jiān)聽(tīng)器。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
listener 指示頁(yè)面更改偵聽(tīng)器。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果 listener 為空。

Since:

4

removePageChangedListener

public void removePageChangedListener(PageSlider.PageChangedListener listener)

刪除以前注冊(cè)的頁(yè)面更改偵聽(tīng)器。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
listener 指示頁(yè)面更改偵聽(tīng)器。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果 listener 為空。

Since:

4

getCurrentSlidingState

public int getCurrentSlidingState()

獲取當(dāng)前的滑動(dòng)狀態(tài)。

返回:

返回當(dāng)前滑動(dòng)狀態(tài),SLIDING_STATE_IDLE、SLIDING_STATE_DRAGGING、SLIDING_STATE_SETTLING 之一。

setOrientation

public void setOrientation(int orientation)

設(shè)置頁(yè)面滑動(dòng)方向,可以是Component.HORIZONTAL或Component.VERTICAL。

默認(rèn)情況下,頁(yè)面在水平方向滑動(dòng)。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
orientation 指示頁(yè)面滑動(dòng)方向。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果方向既不是 Component.HORIZONTAL 也不是 Component.VERTICAL。

getOrientation

public int getOrientation()

獲取頁(yè)面滑動(dòng)方向,可以是Component.HORIZONTAL或Component.VERTICAL。 默認(rèn)情況下,頁(yè)面在水平方向滑動(dòng)。

返回:

返回頁(yè)面滑動(dòng)方向,默認(rèn)為 Component.HORIZONTAL。

setPageMargin

public void setPageMargin(int margin)

設(shè)置頁(yè)面之間的邊距。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
margin 指示頁(yè)面之間的邊距,以像素為單位。

Since:

5

getPageMargin

public int getPageMargin()

獲取頁(yè)面之間的邊距。

返回:

margin 返回頁(yè)面之間的邊距,以像素為單位。

Since:

5

setPageCacheSize

public void setPageCacheSize(int cacheSize)

設(shè)置要保留在當(dāng)前頁(yè)面兩側(cè)的頁(yè)面數(shù)。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
cacheSize 指示要在當(dāng)前頁(yè)面的任一側(cè)保留的頁(yè)面數(shù)。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果 count <= 0。

Since:

4

getCachedPagesLimit

public int getCachedPagesLimit()

獲取當(dāng)前頁(yè)面兩側(cè)要保留的頁(yè)面數(shù)。

返回:

返回要保留在當(dāng)前頁(yè)面兩側(cè)的頁(yè)面數(shù)。

setCurrentPage

public void setCurrentPage(int itemPos)

設(shè)置選定的頁(yè)面。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
itemPos 表示所選頁(yè)面的位置索引。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果 itemPos < 0。

setCurrentPage

public void setCurrentPage(int itemPos, boolean smoothScroll)

設(shè)置當(dāng)前選擇的頁(yè)面。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
itemPos 要選擇的頁(yè)面索引。
smoothScroll 是一種模式:true 表示平滑滾動(dòng),false 表示立即滾動(dòng)。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果 itemPos < 0。

setSlidingPossible

public void setSlidingPossible(boolean enable)

設(shè)置是否開(kāi)啟頁(yè)面滑動(dòng)。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
enable true 表示開(kāi)啟頁(yè)面滑動(dòng); false 表示其他情況。

getSlidingPossible

public boolean getSlidingPossible()

獲取是否開(kāi)啟頁(yè)面滑動(dòng)。 默認(rèn)情況下,頁(yè)面滑動(dòng)是啟用的。

返回:

如果啟用了頁(yè)面滑動(dòng),則返回 true; 否則返回 false。

setCircularModeEnabled

public void setCircularModeEnabled(boolean enabled)

設(shè)置是否為 PageSlider 啟用循環(huán)模式。

應(yīng)用循環(huán)模式后,PageSlider 中的頁(yè)面將在用戶滑動(dòng)時(shí)循環(huán)顯示。 也就是說(shuō),當(dāng)用戶從最后一頁(yè)滑動(dòng)得更遠(yuǎn)時(shí),將顯示第一頁(yè),反之亦然。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
enabled 指定是否啟用循環(huán)模式。

Since:

5

isCircularModeEnabled

public boolean isCircularModeEnabled()

檢查是否為 PageSlider 啟用了循環(huán)模式。

返回:

如果啟用循環(huán)模式,則返回 true; 否則返回 false。

Since:

5

setReboundEffect

public void setReboundEffect(boolean enabled)

設(shè)置是否開(kāi)啟反彈效果。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
enabled 指定是否啟用反彈效果。 true 表示開(kāi)啟反彈效果; false 表示關(guān)閉反彈效果。

getReboundEffect

public boolean getReboundEffect()

獲取反彈效果的狀態(tài)。

返回:

如果啟用了反彈效果,則返回 true; 否則返回 false。

setReboundEffectParams

public void setReboundEffectParams(int overscrollPercent, float overscrollRate, int remainVisiblePercent)

配置回彈效果參數(shù)。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
overscrollPercent 表示過(guò)度滾動(dòng)百分比(默認(rèn)值:40)。 如果滾動(dòng)內(nèi)容的百分比超過(guò)該參數(shù)的值,則內(nèi)容滾動(dòng)速度受 overscrollRate 參數(shù)的影響。 具體來(lái)說(shuō),如果 overscrollRate 的值小于 1.0,則您的手指移動(dòng)速度快于內(nèi)容。
overscrollRate 表示過(guò)度滾動(dòng)率(默認(rèn)值:0.6)。 如果滾動(dòng)內(nèi)容的百分比超過(guò) overscrollPercent 參數(shù)的值,此參數(shù)會(huì)影響內(nèi)容滾動(dòng)速度。 具體來(lái)說(shuō),內(nèi)容滾動(dòng)速度等于手指滾動(dòng)速度乘以overscrollRate的值。
remainVisiblePercent 指示在過(guò)度滾動(dòng)期間應(yīng)保持可見(jiàn)的可滾動(dòng)內(nèi)容的最小百分比。 默認(rèn)值為 20。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果至少滿足以下條件之一: (1) overscrollPercent 不在 [0, 100] 范圍內(nèi) (2) overscrollRate <= 0 (3)保持可見(jiàn)百分比不在 [0, 100] 范圍內(nèi)

Since:

4

setReboundEffectParams

public void setReboundEffectParams(PageSlider.ReboundEffectParams reboundEffectParams)

設(shè)置回彈效果參數(shù)。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
reboundEffectParams 表示一個(gè)包含反彈效果參數(shù)的 ReboundEffectParams 對(duì)象。

Throws:

Throw名稱(chēng) Throw描述
IllegalArgumentException 如果反彈效果參數(shù)為空或包含無(wú)效值。

Since:

4

getReboundEffectParams

public PageSlider.ReboundEffectParams getReboundEffectParams()

獲取反彈參數(shù)作為 ReboundEffectParams 對(duì)象。

返回:

返回包含反彈參數(shù)的 ReboundEffectParams 對(duì)象。

Since:

4

setPageSwitchTime

public void setPageSwitchTime(int durationMs)

設(shè)置頁(yè)面切換時(shí)間。

在通過(guò) API 選擇頁(yè)面或用于結(jié)算頁(yè)面的情況下,PageSlider 移動(dòng)具有此值的頁(yè)面。 默認(rèn)情況下,頁(yè)面切換時(shí)間為 300ms。 如果為 0 或負(fù)值,則將使用默認(rèn)值。

參數(shù):

參數(shù)名稱(chēng) 參數(shù)描述
durationMs 表示頁(yè)面切換,時(shí)間以毫秒為單位。

Since:

4

getPageSwitchTime

public int getPageSwitchTime()

獲取頁(yè)面切換時(shí)間。

返回:

頁(yè)面切換時(shí)間,以毫秒為單位。

Since:

4

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)