ComponentParentpublic class PageSlider extends StackLayout
As a container class, it allows you to add other components. A PageSliderProvider must
be set to generate pages that the component shows.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
PageSlider.PageChangedListener |
Provides a listener to observe page change events.
|
static class |
PageSlider.ReboundEffectParams |
Represents rebound effect parameters.
|
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.VoiceEventComponentContainer.ArrangeListenerStackLayout.LayoutConfig| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
DEFAULT_CACHED_PAGES_LIMIT |
Indicates the minimum number of pages to retain on either side of the current page.
|
static int |
INVALID_INDEX |
Indicates an invalid position.
|
static float |
ROTATION_SENSITIVITY_DEFAULT |
Indicates the default rotation sensitivity of
PageSlider to respond to rotating crown events. |
static float |
ROTATION_SENSITIVITY_HIGH |
Indicates the high rotation sensitivity of
PageSlider to respond to rotating crown events. |
static float |
ROTATION_SENSITIVITY_LOW |
Indicates the low rotation sensitivity of
PageSlider to respond to rotating crown events. |
static int |
SLIDING_STATE_DRAGGING |
Indicates that the user is currently swiping through pages.
|
static int |
SLIDING_STATE_IDLE |
Indicates that the current page is fully in component and no animation is in progress.
|
static int |
SLIDING_STATE_SETTLING |
Indicates that the page has been scrolled to a final position.
|
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, VISIBLEFOCUS_CHILDREN_FIRST, FOCUS_CHILDREN_HIDE, FOCUS_PARENT_FIRST, mArrangeListener| 构造器 | 说明 |
|---|---|
PageSlider(Context context) |
Default constructor used to create a
PageSlider instance by using the default attribute set and style. |
PageSlider(Context context,
AttrSet attrSet) |
A constructor used to create a
PageSlider instance by using specified attribute set and default
style after the XML file is parsed. |
PageSlider(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
PageSlider instance by using specified attribute set and specified style
after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addPageChangedListener(PageSlider.PageChangedListener listener) |
Registers a listener that listens for page change events.
|
int |
getCachedPagesLimit() |
Obtains the number of pages to retain on either side of the current page.
|
int |
getCurrentPage() |
Obtains the selected page.
|
int |
getCurrentSlidingState() |
Obtains the current sliding state.
|
int |
getOrientation() |
Obtains the page sliding direction, which can be
Component.HORIZONTAL or Component.VERTICAL. |
int |
getPageMargin() |
Obtains the margin between pages.
|
int |
getPageSwitchTime() |
Obtains a page switch time.
|
PageSliderProvider |
getProvider() |
Obtains the pager adapter that provides components for the current page.
|
boolean |
getReboundEffect() |
Obtains the state of the rebound effect.
|
PageSlider.ReboundEffectParams |
getReboundEffectParams() |
Obtains the rebound parameters as the
ReboundEffectParams object. |
boolean |
getSlidingPossible() |
Obtains whether page sliding is enabled.
|
boolean |
isCircularModeEnabled() |
Checks whether circular mode is enabled for the
PageSlider. |
void |
removePageChangedListener(PageSlider.PageChangedListener listener) |
Removes a previously registered page change listener.
|
void |
setCircularModeEnabled(boolean enabled) |
Sets whether to enable circular mode for the
PageSlider. |
void |
setCurrentPage(int itemPos) |
Sets the selected page.
|
void |
setCurrentPage(int itemPos,
boolean smoothScroll) |
Sets the currently selected page.
|
void |
setOrientation(int orientation) |
Sets the page sliding direction, which can be
Component.HORIZONTAL or Component.VERTICAL. |
void |
setPageCacheSize(int cacheSize) |
Sets the number of pages to retain on either side of the current page.
|
void |
setPageMargin(int margin) |
Sets the margin between pages.
|
void |
setPageSwitchTime(int durationMs) |
Set a page switch time.
|
void |
setProvider(PageSliderProvider provider) |
Sets a pager adapter that provides components for the current page.
|
void |
setReboundEffect(boolean enabled) |
Sets whether to enable the rebound effect.
|
void |
setReboundEffectParams(int overscrollPercent,
float overscrollRate,
int remainVisiblePercent) |
Configure rebound effect parameters.
|
void |
setReboundEffectParams(PageSlider.ReboundEffectParams reboundEffectParams) |
Sets rebound effect parameters.
|
void |
setSlidingPossible(boolean enable) |
Sets whether to enable page sliding.
|
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, unsubscribeVoiceEventsaddComponent, 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, setTouchEventSplitablegetComponentParent, postLayoutclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateLayoutConfig, verifyLayoutConfigpublic static final int DEFAULT_CACHED_PAGES_LIMIT
public static final int INVALID_INDEX
public static final float ROTATION_SENSITIVITY_DEFAULT
PageSlider to respond to rotating crown events.
You can use Component.setRotationSensitivity(float) to set.public static final float ROTATION_SENSITIVITY_HIGH
PageSlider to respond to rotating crown events.
You can use Component.setRotationSensitivity(float) to set.public static final float ROTATION_SENSITIVITY_LOW
PageSlider to respond to rotating crown events.
You can use Component.setRotationSensitivity(float) to set.public static final int SLIDING_STATE_DRAGGING
public static final int SLIDING_STATE_IDLE
public static final int SLIDING_STATE_SETTLING
public PageSlider(Context context)
PageSlider instance by using the default attribute set and style.context - Indicates the application context.public PageSlider(Context context, AttrSet attrSet)
PageSlider instance by using specified attribute set and default
style after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.public PageSlider(Context context, AttrSet attrSet, String styleName)
PageSlider instance by using specified attribute set and specified style
after the XML file is parsed.context - Indicates the application context.attrSet - Indicates the attribute set to be used.styleName - Indicates the style name to use.public void setProvider(PageSliderProvider provider)
provider - Indicates the pager adapter.public PageSliderProvider getProvider()
null otherwise.public int getCurrentPage()
INVALID_INDEX if no
pager adapter is allocated.public void addPageChangedListener(PageSlider.PageChangedListener listener)
listener - Indicates the page change listener.IllegalArgumentException - if listener is null.public void removePageChangedListener(PageSlider.PageChangedListener listener)
listener - Indicates the page change listener.IllegalArgumentException - if listener is null.public int getCurrentSlidingState()
SLIDING_STATE_IDLE, SLIDING_STATE_DRAGGING,
SLIDING_STATE_SETTLING.public void setOrientation(int orientation)
Component.HORIZONTAL or Component.VERTICAL.
By default, a page slides in the horizontal direction.
orientation - Indicates the page sliding direction.IllegalArgumentException - if orientation is neither Component.HORIZONTAL
nor Component.VERTICAL.public int getOrientation()
Component.HORIZONTAL or Component.VERTICAL. By default, the
page slides in the horizontal direction.Component.HORIZONTAL by default.setOrientation(int)public void setPageMargin(int margin)
margin - Indicates the margin between pages, in pixels.getPageMargin()public int getPageMargin()
setPageMargin(int)public void setPageCacheSize(int cacheSize)
cacheSize - Indicates the number of pages to retain on either side of the current page.IllegalArgumentException - if count <= 0.public int getCachedPagesLimit()
public void setCurrentPage(int itemPos)
itemPos - Indicates the position index of the selected page.IllegalArgumentException - if itemPos < 0.public void setCurrentPage(int itemPos,
boolean smoothScroll)
itemPos - the Page index to select.smoothScroll - is a mode: true for a smooth scroll, false for an immediately scroll.IllegalArgumentException - if itemPos < 0.public void setSlidingPossible(boolean enable)
enable - true indicates that page sliding is enabled; false indicates otherwise.getSlidingPossible()public boolean getSlidingPossible()
true if page sliding is enabled; returns false otherwise.setSlidingPossible(boolean)public void setCircularModeEnabled(boolean enabled)
PageSlider.
With circular mode applied, pages in the PageSlider will be displayed in a loop while the user is
swiping across them. That is, the first page will be displayed when the user swipes further from the last
page, and vice versa.
enabled - Specifies whether to enable circular mode.isCircularModeEnabled()public boolean isCircularModeEnabled()
PageSlider.true if circular mode is enabled; returns false otherwise.setCircularModeEnabled(boolean)public void setReboundEffect(boolean enabled)
enabled - Specifies whether to enable the rebound effect. true indicates to enable the rebound
effect; false indicates to disable the rebound effect.public boolean getReboundEffect()
true if the rebound effect is enabled; returns false otherwise.public void setReboundEffectParams(int overscrollPercent,
float overscrollRate,
int remainVisiblePercent)
overscrollPercent - Indicates the overscroll percent (default value: 40). If the percent of
scrolled content exceeds the value of this parameter, the content scrolling speed is affected by the
overscrollRate parameter. Specifically, if the value of overscrollRate is less than
1.0, your finger moves faster than the content.overscrollRate - Indicates the overscroll rate (default value: 0.6). This parameter affects the
content scrolling speed if the percent of scrolled content exceeds the value of the
overscrollPercent parameter. Specifically, the content scrolling speed is equal to the finger
scrolling speed multiplied by the value of overscrollRate.remainVisiblePercent - Indicates the minimum percent of scrollable content that should remain visible
during overscrolling. The default value is 20.IllegalArgumentException - if at least one of the following conditions is true:
(1) overscrollPercent is not in range [0, 100] (2) overscrollRate <= 0
(3) remainVisiblePercent is not in range [0, 100]public void setReboundEffectParams(PageSlider.ReboundEffectParams reboundEffectParams)
reboundEffectParams - Indicates a ReboundEffectParams object holding the rebound effect parameters.IllegalArgumentException - if reboundEffectParams is null or contains invalid value.getReboundEffectParams(),
setReboundEffectParams(int, float, int)public PageSlider.ReboundEffectParams getReboundEffectParams()
ReboundEffectParams object.ReboundEffectParams object holding the rebound parameters.setReboundEffectParams(ReboundEffectParams),
setReboundEffectParams(int, float, int)public void setPageSwitchTime(int durationMs)
The PageSlider moves pages with this value in cases of the either select page via API or for settling page. By default, the page switch time is 300ms. In case either 0 or negative value the default value will be used.
durationMs - Indicates the page switch, time in millisecs.getPageSwitchTime()public int getPageSwitchTime()
setPageSwitchTime(int)