public class WheelPicker extends android.view.View implements IDebug, IWheelPicker, Runnable
WheelPicker
New project structure
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
WheelPicker.OnItemSelectedListener
滚轮选择器Item项被选中时监听接口
|
static interface |
WheelPicker.OnWheelChangeListener
滚轮选择器滚动时监听接口
|
android.view.View.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnApplyWindowInsetsListener, android.view.View.OnAttachStateChangeListener, android.view.View.OnClickListener, android.view.View.OnContextClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnScrollChangeListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener| 限定符和类型 | 字段和说明 |
|---|---|
static int |
ALIGN_CENTER
数据项对齐方式标识值
|
static int |
ALIGN_LEFT
数据项对齐方式标识值
|
static int |
ALIGN_RIGHT
数据项对齐方式标识值
|
static int |
SCROLL_STATE_DRAGGING
滚动状态标识值
|
static int |
SCROLL_STATE_IDLE
滚动状态标识值
|
static int |
SCROLL_STATE_SCROLLING
滚动状态标识值
|
ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLL_AXIS_HORIZONTAL, SCROLL_AXIS_NONE, SCROLL_AXIS_VERTICAL, SCROLL_INDICATOR_BOTTOM, SCROLL_INDICATOR_END, SCROLL_INDICATOR_LEFT, SCROLL_INDICATOR_RIGHT, SCROLL_INDICATOR_START, SCROLL_INDICATOR_TOP, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_IMMERSIVE, SYSTEM_UI_FLAG_IMMERSIVE_STICKY, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_FIRST_STRONG_LTR, TEXT_DIRECTION_FIRST_STRONG_RTL, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, TRANSLATION_Z, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y, Z| 构造器和说明 |
|---|
WheelPicker(android.content.Context context) |
WheelPicker(android.content.Context context,
android.util.AttributeSet attrs) |
| 限定符和类型 | 方法和说明 |
|---|---|
int |
getCurrentItemPosition()
获取当前被选中的数据项所显示的数据在数据源中的位置
与
IWheelPicker.getSelectedItemPosition()不同的是,该方法所返回的结果会因为滚轮选择器的改变而改变
Get the position of current selected item in data source
The difference between IWheelPicker.getSelectedItemPosition(), the value this method return will
change by WheelPicker scrolled |
int |
getCurtainColor()
获取滚轮选择器幕布颜色
Get color of curtain
For example 0xFF123456
|
List |
getData()
获取数据列表
Get data source of WheelPicker
|
int |
getIndicatorColor()
获取滚轮选择器指示器颜色
Get color of indicator
For example 0xFF123456
|
int |
getIndicatorSize()
获取滚轮选择器指示器尺寸
Get size of indicator
Unit in px
|
int |
getItemAlign()
获取滚轮选择器数据项的对齐方式
Get alignment of WheelPicker
|
int |
getItemSpace()
获取滚轮选择器数据项之间间距
Get space between items
Unit in px
|
int |
getItemTextColor()
获取数据项文本颜色
Get text color of items
For example 0xFF123456
|
int |
getItemTextSize()
获取数据项文本尺寸大小
Get text size of items
Unit in px
|
String |
getMaximumWidthText()
获取最宽的文本
Get maximum width text
|
int |
getMaximumWidthTextPosition()
获取最宽的文本在数据源中的位置
Get the position of maximum width text in data source
|
int |
getSelectedItemPosition()
获取当前被选中的数据项所显示的数据在数据源中的位置
需要注意的是,当滚轮选择器滚动时并不会改变该方法的返回值,该方法会始终返回
IWheelPicker.setSelectedItemPosition(int)所设置的值,当且仅当调用
IWheelPicker.setSelectedItemPosition(int)设置新值后,该方法所返回的值才会改变
如果你只是想获取滚轮静止时当前被选中的数据项所显示的数据在数据源中的位置,你可以通过
WheelPicker.OnItemSelectedListener回调监听或调用
IWheelPicker.getCurrentItemPosition()
Get the position of current selected item in data source
Notice:The value by return will not change when WheelPicker scroll, this method will always
return the value which IWheelPicker.setSelectedItemPosition(int) set, the value this method
return will be changed if and only if call the
IWheelPicker.setSelectedItemPosition(int)
set a new value
If you only want to get the position of current selected item in data source, you can get it
through WheelPicker.OnItemSelectedListener or call
IWheelPicker.getCurrentItemPosition() directly |
int |
getSelectedItemTextColor()
获取当前选中的数据项文本颜色
Get text color of current selected item
For example 0xFF123456
|
android.graphics.Typeface |
getTypeface()
获取数据项文本字体对象
Get typeface of item text
|
int |
getVisibleItemCount()
获取滚轮选择器可见数据项的数量
Get the count of current visible items in WheelPicker
|
boolean |
hasAtmospheric()
滚轮选择器是否有空气感
Whether WheelPicker has atmospheric or not
|
boolean |
hasCurtain()
滚轮选择器是否显示幕布
Whether WheelPicker display curtain or not
|
boolean |
hasIndicator()
滚轮选择器是否有指示器
Whether WheelPicker display indicator or not
|
boolean |
hasSameWidth()
数据项是否有相同宽度
Whether items has same width or not
|
boolean |
isCurved()
滚轮选择器是否开启卷曲效果
Whether WheelPicker enable curved effect or not
|
boolean |
isCyclic()
滚轮选择器数据项是否为循环状态
Whether WheelPicker is cyclic or not
|
protected void |
onDraw(android.graphics.Canvas canvas) |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec) |
protected void |
onSizeChanged(int w,
int h,
int oldW,
int oldH) |
boolean |
onTouchEvent(android.view.MotionEvent event) |
void |
run() |
void |
setAtmospheric(boolean hasAtmospheric)
设置滚轮选择器是否有空气感
开启空气感的滚轮选择器将呈现中间不透明逐渐向两端透明过度的渐变效果
Set whether WheelPicker has atmospheric or not
WheelPicker's items will be transparent from center to ends if atmospheric display
|
void |
setCurtain(boolean hasCurtain)
设置滚轮选择器是否显示幕布
设置滚轮选择器显示幕布的话将会在当前选中的项上方绘制一个与当前数据项大小一致的矩形区域并填充指定颜色
Set whether WheelPicker display curtain or not
WheelPicker will draw a rectangle as big as current selected item and fill specify color
above content if curtain display
|
void |
setCurtainColor(int color)
设置滚轮选择器幕布颜色
Set color of curtain
For example 0xFF123456
|
void |
setCurved(boolean isCurved)
设置滚轮选择器是否开启卷曲效果
开启滚轮选择器的滚轮效果会呈现一种滚轮两端向屏幕内弯曲的效果
滚轮选择器的卷曲效果依赖于严格的几何模型,一些与尺寸相关的设置在该效果下可能会变得不再有效,例如在卷
曲效果下每一条数据项的尺寸大小因为透视关系看起来都不再一样,数据项之间的间隔也会因为卷曲的关系有微妙
的视觉差距
Set whether WheelPicker enable curved effect or not
If setCurved true, WheelPicker will display with curved effect looks like ends bend into
screen with perspective.
|
void |
setCyclic(boolean isCyclic)
设置滚轮选择器数据项是否为循环状态
开启数据循环会使滚轮选择器上下滚动不再有边界,会呈现数据首尾相接无限循环的效果
Set whether WheelPicker is cyclic or not
WheelPicker's items will be end to end and in an infinite loop if setCyclic true, and there
is no border whit scroll when WheelPicker in cyclic state
|
void |
setData(List data)
设置数据列表
数据源可以是任意类型,但是需要注意的是WheelPicker在绘制数据的时候会将数据转换成String类型
在没有设置数据源的情况下滚轮选择器会设置一个默认的数据源作为展示
为滚轮选择器设置数据源会重置滚轮选择器的各项状态,具体行为参考
IWheelPicker.setSelectedItemPosition(int)
Set data source of WheelPicker
The data source can be any type, WheelPicker will change the data to string when it draw the
item. |
void |
setDebug(boolean isDebug)
设置调试模式
开启调试模式有可能在一定程度上降低代码执行效率,请务必在正式发布时关闭调试模式
|
void |
setIndicator(boolean hasIndicator)
设置滚轮选择器是否显示指示器
如果设置滚轮选择器显示指示器,那么将会在滚轮选择器的当前选中数据项上下显示两根分割线
需要注意的是指示器的尺寸并不参与滚轮选择器的尺寸计算,其会绘制在滚轮选择器的上方
Set whether WheelPicker display indicator or not
WheelPicker will draw two lines above an below current selected item if display indicator
Notice:Indicator's size will not participate in WheelPicker's size calculation, it will drawn
above the content
|
void |
setIndicatorColor(int color)
设置滚轮选择器指示器颜色
Set color of indicator
For example 0xFF123456
|
void |
setIndicatorSize(int size)
设置滚轮选择器指示器尺寸
Set size of indicator
Unit in px
|
void |
setItemAlign(int align)
设置滚轮选择器数据项的对齐方式
默认对齐方式为居中对齐
ALIGN_CENTER
Set alignment of WheelPicker
The default alignment of WheelPicker is ALIGN_CENTER |
void |
setItemSpace(int space)
设置滚轮选择器数据项之间间距
Set space between items
Unit in px
|
void |
setItemTextColor(int color)
设置数据项文本颜色
Set text color of items
For example 0xFF123456
|
void |
setItemTextSize(int size)
设置数据项文本尺寸大小
Set text size of items
Unit in px
|
void |
setMaximumWidthText(String text)
设置最宽的文本
Set maximum width text
|
void |
setMaximumWidthTextPosition(int position)
设置最宽的文本在数据源中的位置
Set the position of maximum width text in data source
|
void |
setOnItemSelectedListener(WheelPicker.OnItemSelectedListener listener)
设置滚轮Item选中监听器
|
void |
setOnWheelChangeListener(WheelPicker.OnWheelChangeListener listener)
设置滚轮滚动状态改变监听器
|
void |
setSameWidth(boolean hasSameWidth)
设置数据项是否有相同的宽度
滚轮选择器在确定尺寸大小时会通过遍历数据源来计算每一条数据文本的宽度以找到最宽的文本作为滚轮选择器的
最终宽度,当数据源的数据非常多时,这个过程可能会消耗大量的时间导致效率降低,而且在大部分数据量多情况
下,数据文本大都有相同的宽度,这种情况下调用该方法告诉滚轮选择器数据宽度相同则可以免去上述计算时间,
提升效率
有些时候,你所加载的数据源确实是每条数据文本的宽度都不同,但是你知道最宽的数据文本在数据源中的位置,
这时你可以调用
IWheelPicker.setMaximumWidthTextPosition(int)方法告诉滚轮选择器最宽的这条数据文本在数据
源的什么位置,滚轮选择器则会根据该位置找到该条数据文本并将其宽度作为滚轮选择器的宽度。 |
void |
setSelectedItemPosition(int position)
设置当前被选中的数据项所显示的数据在数据源中的位置
调用该方法会导致滚动选择器的位置被重新初始化,什么意思呢?
|
void |
setSelectedItemTextColor(int color)
设置当前选中的数据项文本颜色
Set text color of current selected item
For example 0xFF123456
|
void |
setTypeface(android.graphics.Typeface tf)
设置数据项文本字体对象
数据项文本字体的设置可能会导致滚轮大小的改变
Set typeface of item text
Set typeface of item text maybe cause WheelPicker size change
|
void |
setVisibleItemCount(int count)
设置滚轮选择器可见数据项数量
滚轮选择器的可见数据项数量必须为大于1的整数
这里需要注意的是,滚轮选择器会始终显示奇数个数据项,即便你为其设置偶数个数据项,最终也会被转换为奇数
默认情况下滚轮选择器可见数据项数量为7
Set the count of current visible items in WheelPicker
The count of current visible items in WheelPicker must greater than 1
Notice:count of current visible items in WheelPicker will always is an odd number, even you
can set an even number for it, it will be change to an odd number eventually
By default, the count of current visible items in WheelPicker is 7
|
addChildrenForAccessibility, addFocusables, addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, animate, announceForAccessibility, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, cancelPendingInputEvents, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAnimation, clearFocus, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, destroyDrawingCache, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPopulateAccessibilityEvent, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, drawableHotspotChanged, drawableStateChanged, findFocus, findViewById, findViewsWithText, findViewWithTag, fitSystemWindows, focusSearch, forceLayout, generateViewId, getAccessibilityClassName, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getImportantForAccessibility, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOutlineProvider, getOverlay, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRootWindowInsets, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollIndicators, getScrollX, getScrollY, getSolidColor, getStateListAnimator, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, hasFocus, hasFocusable, hasNestedScrollingParent, hasOnClickListeners, hasOverlappingRendering, hasTransientState, hasWindowFocus, inflate, invalidate, invalidate, invalidate, invalidateDrawable, invalidateOutline, isAccessibilityFocused, isActivated, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInTouchMode, isLaidOut, isLayoutDirectionResolved, isLayoutRequested, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTextAlignmentResolved, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, jumpDrawablesToCurrentState, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onAttachedToWindow, onCancelPendingInputEvents, onCheckIsTextEditor, onConfigurationChanged, onCreateContextMenu, onCreateDrawableState, onCreateInputConnection, onDetachedFromWindow, onDisplayHint, onDragEvent, onDrawForeground, onDrawScrollBars, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onOverScrolled, onPopulateAccessibilityEvent, onProvideStructure, onProvideVirtualStructure, onRestoreInstanceState, onRtlPropertiesChanged, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, overScrollBy, performAccessibilityAction, performClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resolveSize, resolveSizeAndState, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionName, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, startActionMode, startActionMode, startAnimation, startDrag, startNestedScroll, stopNestedScroll, toString, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDrawpublic static final int SCROLL_STATE_IDLE
public static final int SCROLL_STATE_DRAGGING
public static final int SCROLL_STATE_SCROLLING
public static final int ALIGN_CENTER
setItemAlign(int),
常量字段值public static final int ALIGN_LEFT
setItemAlign(int),
常量字段值public static final int ALIGN_RIGHT
setItemAlign(int),
常量字段值public WheelPicker(android.content.Context context)
public WheelPicker(android.content.Context context,
android.util.AttributeSet attrs)
protected void onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
onMeasure 在类中 android.view.Viewprotected void onSizeChanged(int w,
int h,
int oldW,
int oldH)
onSizeChanged 在类中 android.view.Viewprotected void onDraw(android.graphics.Canvas canvas)
onDraw 在类中 android.view.Viewpublic boolean onTouchEvent(android.view.MotionEvent event)
onTouchEvent 在类中 android.view.Viewpublic void setDebug(boolean isDebug)
IDebugpublic int getVisibleItemCount()
IWheelPickerGet the count of current visible items in WheelPicker
getVisibleItemCount 在接口中 IWheelPickerpublic void setVisibleItemCount(int count)
IWheelPickerSet the count of current visible items in WheelPicker The count of current visible items in WheelPicker must greater than 1 Notice:count of current visible items in WheelPicker will always is an odd number, even you can set an even number for it, it will be change to an odd number eventually By default, the count of current visible items in WheelPicker is 7
setVisibleItemCount 在接口中 IWheelPickercount - 滚轮选择器可见数据项数量public boolean isCyclic()
IWheelPickerWhether WheelPicker is cyclic or not
isCyclic 在接口中 IWheelPickerpublic void setCyclic(boolean isCyclic)
IWheelPickerSet whether WheelPicker is cyclic or not WheelPicker's items will be end to end and in an infinite loop if setCyclic true, and there is no border whit scroll when WheelPicker in cyclic state
setCyclic 在接口中 IWheelPickerisCyclic - 是否为循环状态public void setOnItemSelectedListener(WheelPicker.OnItemSelectedListener listener)
IWheelPickersetOnItemSelectedListener 在接口中 IWheelPickerlistener - 滚轮Item选中监听器WheelPicker.OnItemSelectedListenerpublic int getSelectedItemPosition()
IWheelPickerIWheelPicker.setSelectedItemPosition(int)所设置的值,当且仅当调用
IWheelPicker.setSelectedItemPosition(int)设置新值后,该方法所返回的值才会改变
如果你只是想获取滚轮静止时当前被选中的数据项所显示的数据在数据源中的位置,你可以通过
WheelPicker.OnItemSelectedListener回调监听或调用
IWheelPicker.getCurrentItemPosition()
Get the position of current selected item in data source
Notice:The value by return will not change when WheelPicker scroll, this method will always
return the value which IWheelPicker.setSelectedItemPosition(int) set, the value this method
return will be changed if and only if call the
IWheelPicker.setSelectedItemPosition(int)
set a new value
If you only want to get the position of current selected item in data source, you can get it
through WheelPicker.OnItemSelectedListener or call
IWheelPicker.getCurrentItemPosition() directly
getSelectedItemPosition 在接口中 IWheelPickerpublic void setSelectedItemPosition(int position)
IWheelPickerWheelPicker.OnWheelChangeListener和
WheelPicker.OnItemSelectedListener监听器中方法参数的值,因
此你总该在调用该方法后考虑到相关影响
你总该为该方法传入一个大于等于0小于数据源IWheelPicker.getData()长度
的值,否则会抛出异常
默认情况下,当前被选中的数据项所显示的数据在数据源中的位置为0
Set the position of current selected item in data source
Call this method and set a new value may be reinitialize the location of WheelPicker. For
example, you call this method after scroll the WheelPicker and set selected item position
with a new value, WheelPicker will clear the related parameters last scroll set and reset
series of data, and make the position 3 as a new starting point of WheelPicker, this behavior
maybe influenced some attribute you set last time, such as parameters of method in
WheelPicker.OnWheelChangeListener and
WheelPicker.OnItemSelectedListener, so you must always
consider the influence when you call this method set a new value
You should always set a value which greater than or equal to 0 and less than data source's
length
By default, position of current selected item in data source is 0
setSelectedItemPosition 在接口中 IWheelPickerposition - 当前被选中的数据项所显示的数据在数据源中的位置public int getCurrentItemPosition()
IWheelPickerIWheelPicker.getSelectedItemPosition()不同的是,该方法所返回的结果会因为滚轮选择器的改变而改变
Get the position of current selected item in data source
The difference between IWheelPicker.getSelectedItemPosition(), the value this method return will
change by WheelPicker scrolled
getCurrentItemPosition 在接口中 IWheelPickerpublic List getData()
IWheelPickerGet data source of WheelPicker
getData 在接口中 IWheelPickerpublic void setData(List data)
IWheelPickerIWheelPicker.setSelectedItemPosition(int)
Set data source of WheelPicker
The data source can be any type, WheelPicker will change the data to string when it draw the
item.
There is a default data source when you not set the data source for WheelPicker.
Set data source for WheelPicker will reset state of it, you can refer to
IWheelPicker.setSelectedItemPosition(int) for more details.
setData 在接口中 IWheelPickerdata - 数据列表public void setSameWidth(boolean hasSameWidth)
IWheelPickerIWheelPicker.setMaximumWidthTextPosition(int)方法告诉滚轮选择器最宽的这条数据文本在数据
源的什么位置,滚轮选择器则会根据该位置找到该条数据文本并将其宽度作为滚轮选择器的宽度。如果你不知道位
置,但是知道最宽的数据文本,那么你也可以直接通过调用IWheelPicker.setMaximumWidthText(String)告诉滚轮选
择器最宽的文本是什么,滚轮选择器会根据这条文本计算宽度并将其作为滚轮选择器的宽度
Set items of WheelPicker if has same width
WheelPicker will traverse the data source to calculate each data text width to find out the
maximum text width for the final view width, this process maybe spends a lot of time and
reduce efficiency when data source has large amount data, in most large amount data case,
data text always has same width, you can call this method tell to WheelPicker your data
source has same width to save time and improve efficiency.
Sometimes the data source you set is positively has different text width, but maybe you know
the maximum width text's position in data source, then you can call
IWheelPicker.setMaximumWidthTextPosition(int) tell to WheelPicker where is the maximum width text
in data source, WheelPicker will calculate its width base on this text which found by
position. If you don't know the position of maximum width text in data source, but you have
maximum width text, you can call IWheelPicker.setMaximumWidthText(String) tell to WheelPicker
what maximum width text is directly, WheelPicker will calculate its width base on this text.
setSameWidth 在接口中 IWheelPickerhasSameWidth - 是否有相同的宽度public boolean hasSameWidth()
IWheelPickerWhether items has same width or not
hasSameWidth 在接口中 IWheelPickerpublic void setOnWheelChangeListener(WheelPicker.OnWheelChangeListener listener)
IWheelPickersetOnWheelChangeListener 在接口中 IWheelPickerlistener - 滚轮滚动状态改变监听器WheelPicker.OnWheelChangeListenerpublic String getMaximumWidthText()
IWheelPickerGet maximum width text
getMaximumWidthText 在接口中 IWheelPickerpublic void setMaximumWidthText(String text)
IWheelPickerSet maximum width text
setMaximumWidthText 在接口中 IWheelPickertext - 最宽的文本IWheelPicker.setSameWidth(boolean)public int getMaximumWidthTextPosition()
IWheelPickerGet the position of maximum width text in data source
getMaximumWidthTextPosition 在接口中 IWheelPickerpublic void setMaximumWidthTextPosition(int position)
IWheelPickerSet the position of maximum width text in data source
setMaximumWidthTextPosition 在接口中 IWheelPickerposition - 最宽的文本在数据源中的位置IWheelPicker.setSameWidth(boolean)public int getSelectedItemTextColor()
IWheelPickerGet text color of current selected item For example 0xFF123456
getSelectedItemTextColor 在接口中 IWheelPickerpublic void setSelectedItemTextColor(int color)
IWheelPickerSet text color of current selected item For example 0xFF123456
setSelectedItemTextColor 在接口中 IWheelPickercolor - 当前选中的数据项文本颜色,16位颜色值public int getItemTextColor()
IWheelPickerGet text color of items For example 0xFF123456
getItemTextColor 在接口中 IWheelPickerpublic void setItemTextColor(int color)
IWheelPickerSet text color of items For example 0xFF123456
setItemTextColor 在接口中 IWheelPickercolor - 数据项文本颜色,16位颜色值public int getItemTextSize()
IWheelPickerGet text size of items Unit in px
getItemTextSize 在接口中 IWheelPickerpublic void setItemTextSize(int size)
IWheelPickerSet text size of items Unit in px
setItemTextSize 在接口中 IWheelPickersize - 设置数据项文本尺寸大小,单位:pxpublic int getItemSpace()
IWheelPickerGet space between items Unit in px
getItemSpace 在接口中 IWheelPickerpublic void setItemSpace(int space)
IWheelPickerSet space between items Unit in px
setItemSpace 在接口中 IWheelPickerspace - 滚轮选择器数据项之间间距,单位:pxpublic void setIndicator(boolean hasIndicator)
IWheelPickerSet whether WheelPicker display indicator or not WheelPicker will draw two lines above an below current selected item if display indicator Notice:Indicator's size will not participate in WheelPicker's size calculation, it will drawn above the content
setIndicator 在接口中 IWheelPickerhasIndicator - 是否有指示器public boolean hasIndicator()
IWheelPickerWhether WheelPicker display indicator or not
hasIndicator 在接口中 IWheelPickerpublic int getIndicatorSize()
IWheelPickerGet size of indicator Unit in px
getIndicatorSize 在接口中 IWheelPickerpublic void setIndicatorSize(int size)
IWheelPickerSet size of indicator Unit in px
setIndicatorSize 在接口中 IWheelPickersize - 滚轮选择器指示器尺寸,单位:pxpublic int getIndicatorColor()
IWheelPickerGet color of indicator For example 0xFF123456
getIndicatorColor 在接口中 IWheelPickerpublic void setIndicatorColor(int color)
IWheelPickerSet color of indicator For example 0xFF123456
setIndicatorColor 在接口中 IWheelPickercolor - 滚轮选择器指示器颜色,16位颜色值public void setCurtain(boolean hasCurtain)
IWheelPickerSet whether WheelPicker display curtain or not WheelPicker will draw a rectangle as big as current selected item and fill specify color above content if curtain display
setCurtain 在接口中 IWheelPickerhasCurtain - 滚轮选择器是否显示幕布public boolean hasCurtain()
IWheelPickerWhether WheelPicker display curtain or not
hasCurtain 在接口中 IWheelPickerpublic int getCurtainColor()
IWheelPickerGet color of curtain For example 0xFF123456
getCurtainColor 在接口中 IWheelPickerpublic void setCurtainColor(int color)
IWheelPickerSet color of curtain For example 0xFF123456
setCurtainColor 在接口中 IWheelPickercolor - 滚轮选择器幕布颜色,16位颜色值public void setAtmospheric(boolean hasAtmospheric)
IWheelPickerSet whether WheelPicker has atmospheric or not WheelPicker's items will be transparent from center to ends if atmospheric display
setAtmospheric 在接口中 IWheelPickerhasAtmospheric - 滚轮选择器是否有空气感public boolean hasAtmospheric()
IWheelPickerWhether WheelPicker has atmospheric or not
hasAtmospheric 在接口中 IWheelPickerpublic boolean isCurved()
IWheelPickerWhether WheelPicker enable curved effect or not
isCurved 在接口中 IWheelPickerpublic void setCurved(boolean isCurved)
IWheelPickerSet whether WheelPicker enable curved effect or not If setCurved true, WheelPicker will display with curved effect looks like ends bend into screen with perspective. WheelPicker's curved effect base on strict geometric model, some parameters relate with size maybe invalidated, for example each item size looks like different because of perspective in curved, the space between items looks like have a little difference
setCurved 在接口中 IWheelPickerisCurved - 滚轮选择器是否开启卷曲效果public int getItemAlign()
IWheelPickerGet alignment of WheelPicker
getItemAlign 在接口中 IWheelPickerpublic void setItemAlign(int align)
IWheelPickerALIGN_CENTER
Set alignment of WheelPicker
The default alignment of WheelPicker is ALIGN_CENTER
setItemAlign 在接口中 IWheelPickeralign - 对齐方式标识值
该值仅能是下列值之一:
ALIGN_CENTER
ALIGN_LEFT
ALIGN_RIGHTpublic android.graphics.Typeface getTypeface()
IWheelPickerGet typeface of item text
getTypeface 在接口中 IWheelPickerpublic void setTypeface(android.graphics.Typeface tf)
IWheelPickerSet typeface of item text Set typeface of item text maybe cause WheelPicker size change
setTypeface 在接口中 IWheelPickertf - 字体对象