鴻蒙OS Picker

2022-09-28 10:49 更新

Picker

java.lang.Object

|---ohos.agp.components.Component

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

|---|---|---ohos.agp.components.DirectionalLayout

|---|---|---|---ohos.agp.components.Picker

  1. public class Picker
  2. extends DirectionalLayout

提供一個(gè)數(shù)字選擇器,允許從預(yù)定義的范圍中選擇數(shù)字。

該類配置數(shù)字選擇器的屬性,以便用戶可以在屏幕上的取值范圍內(nèi)選擇特定的數(shù)字。

Since:

3

嵌套類摘要

修飾符和類型 描述
static interface Picker.ElementFormatter 為 Picker 的每一項(xiàng)格式化左右復(fù)合元素對(duì)象。
static interface Picker.Formatter 格式化 Picker 的值并將其轉(zhuǎn)換為字符串。
static interface Picker.ScrolledListener 處理 Picker 實(shí)例的滾動(dòng)事件。
static interface Picker.ValueChangedListener 偵聽(tīng) Picker 實(shí)例的值更改事件。
從類 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.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEvent
從類 ohos.agp.components.ComponentContainer 繼承的嵌套類/接口
ComponentContainer.ArrangeListener
從類 ohos.agp.components.DirectionalLayout 繼承的嵌套類/接口
DirectionalLayout.LayoutConfig

字段摘要

修飾符和類型 字段 描述
static float ROTATION_SENSITIVITY_DEFAULT 指示 Picker 響應(yīng)旋轉(zhuǎn)表冠事件的默認(rèn)旋轉(zhuǎn)靈敏度。
static float ROTATION_SENSITIVITY_HIGH 表示 Picker 響應(yīng)旋轉(zhuǎn)表冠事件的高旋轉(zhuǎn)靈敏度。
static float ROTATION_SENSITIVITY_LOW 指示 Picker 響應(yīng)旋轉(zhuǎn)表冠事件的低旋轉(zhuǎn)靈敏度。
從類 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

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

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

方法總結(jié)

修飾符和類型 方法 描述
int getCompoundElementPadding() 獲取文本和 Element 對(duì)象之間的填充。
Element getDisplayedBottomElement() 獲取用于在選定數(shù)字底部繪制分割線的 Element 實(shí)例。
String[] getDisplayedData() 獲取與要顯示的數(shù)字匹配的字符串?dāng)?shù)組。
Element[] getDisplayedLinesElements() 獲取用于在選定文本的頂部和底部繪制顯示線條的 Element 實(shí)例。
Element getDisplayedTopElement() 獲取用于在選定數(shù)字頂部繪制分割線的 Element 實(shí)例。
Picker.ElementFormatter getElementFormatter() 獲取每個(gè)項(xiàng)目左右顯示的Element的格式化程序。
Picker.Formatter getFormatter() 獲取格式化顯示內(nèi)容的格式化程序。
int getMaxValue() 獲取數(shù)字選擇器的最大值。
int getMinValue() 獲取數(shù)字選擇器的最小值。
Color getNormalTextColor() 獲取數(shù)字選擇器上取消選擇的文本的顏色。
Font getNormalTextFont() 獲取此選取器中普通文本的字體。
int getNormalTextSize() 獲取數(shù)字選擇器上取消選擇的文本的字體大小。
Picker.ScrolledListener getScrollListener() 獲取監(jiān)聽(tīng)picker滾動(dòng)狀態(tài)的監(jiān)聽(tīng)器。
float getSelectedNormalTextMarginRatio() 獲取此數(shù)字選擇器中所選文本邊距與正常文本邊距的比率。
Element getSelectedTextBackgroundElement() 獲取元素集作為此選擇器選擇的文本的背景。
Color getSelectedTextColor() 獲取數(shù)字選擇器上選定文本的顏色。
Font getSelectedTextFont() 獲取此選取器中選定文本的字體。
int getSelectedTextSize() 獲取數(shù)字選擇器上選定文本的字體大小。
int getSelectorItemNum() 獲取選擇輪上顯示的項(xiàng)目數(shù)。
Color getShaderColor() 獲取數(shù)字選擇器的著色器顏色。
int getValue() 獲取數(shù)字選擇器上顯示的值。
Picker.ValueChangedListener getValueChangedListener() 獲取監(jiān)聽(tīng)picker值變化的監(jiān)聽(tīng)器。
boolean isWheelModeEnabled() 獲取數(shù)字選擇器的選擇器包裝模式。
void setCompoundElementPadding(int padding) 設(shè)置文本和元素對(duì)象之間的填充。
void setDisplayedData(String[] displayedData) 設(shè)置要顯示的字符串?dāng)?shù)組。
void setDisplayedLinesBottomElement(Element bottom) 設(shè)置一個(gè) Element 實(shí)例,用于在選定文本的底部繪制一條顯示線。
void setDisplayedLinesElements(Element top, Element bottom) 設(shè)置用于為選定文本繪制分割線的 Element 實(shí)例。
void setDisplayedLinesTopElement(Element top) 設(shè)置一個(gè) Element 實(shí)例,用于在選定文本的頂部繪制一條顯示線。
void setElementFormatter(Picker.ElementFormatter formatter) 設(shè)置格式化程序以格式化顯示在每個(gè)項(xiàng)目的左側(cè)和右側(cè)的元素內(nèi)容。
void setFormatter(Picker.Formatter formatter) 設(shè)置格式化程序以標(biāo)準(zhǔn)化顯示的內(nèi)容。
void setMaxValue(int maxValue) 設(shè)置數(shù)字選擇器的最大值。
void setMinValue(int minValue) 設(shè)置數(shù)字選擇器的最小值。
void setNormalTextColor(Color color) 為數(shù)字選擇器上取消選擇的文本設(shè)置顏色。
void setNormalTextFont(Font font) 設(shè)置此選擇器中普通文本的字體。
void setNormalTextSize(int textSize) 為數(shù)字選擇器上取消選擇的文本設(shè)置字體大小。
void setScrollListener(Picker.ScrolledListener scrollListener) 設(shè)置選擇器的滾動(dòng)狀態(tài)偵聽(tīng)器。
void setSelectedNormalTextMarginRatio(float textMarginRatio) 在此數(shù)字選擇器中設(shè)置所選文本邊距與正常文本邊距的比率。
void setSelectedTextBackground(Element element) 將元素設(shè)置為此選擇器選擇的文本的背景。
void setSelectedTextColor(Color color) 為數(shù)字選擇器上的選定文本設(shè)置顏色。
void setSelectedTextFont(Font font) 設(shè)置此選取器中選定文本的字體。
void setSelectedTextSize(int textSize) 為數(shù)字選擇器上的選定文本設(shè)置字體大小。
void setSelectorItemNum(int itemNum) 設(shè)置要在選擇器上顯示的項(xiàng)目數(shù)。
void setShaderColor(Color color) 為數(shù)字選擇器設(shè)置著色器顏色。
void setValue(int value) 設(shè)置數(shù)字選擇器上的當(dāng)前值。
void setValueChangedListener(Picker.ValueChangedListener valueChangedListener) 設(shè)置數(shù)字選擇器的值更改偵聽(tīng)器。
boolean setWheelModeEnabled(boolean isEnabled) 設(shè)置Selector Wheel模式,該模式確定Picker#GetMinvalue()和Picker#getMaxValue()的值是否在最大范圍內(nèi)滾動(dòng)滾動(dòng)時(shí)彼此相鄰顯示。
從類 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, removeComponents, setArrangeListener, setAutoLayout, setAutoLayout, setClipToChildBoundsEnabled, setClipToPaddingBoundsEnabled, setComponentTransition, setFocusOrder, setLayoutManager, setTouchEventSplitable
從接口 ohos.agp.components.ComponentParent 繼承的方法
getComponentParent, postLayout
從類 ohos.agp.components.DirectionalLayout 繼承的方法
createLayoutConfig, getAlignment, getOrientation, getTotalWeight, isLayoutBaselined, setAlignment, setLayoutBaselined, setOrientation, setTotalWeight, verifyLayoutConfig
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

字段詳細(xì)信息

ROTATION_SENSITIVITY_DEFAULT

public static final float ROTATION_SENSITIVITY_DEFAULT

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

ROTATION_SENSITIVITY_HIGH

public static final float ROTATION_SENSITIVITY_HIGH

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

ROTATION_SENSITIVITY_LOW

public static final float ROTATION_SENSITIVITY_LOW

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

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

Picker

public Picker(Context context)

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

參數(shù):

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

Picker

public Picker(Context context, AttrSet attrSet)

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

參數(shù):

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

Picker

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

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

參數(shù):

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

方法詳情

setSelectorItemNum

public void setSelectorItemNum(int itemNum)

設(shè)置要在選擇器上顯示的項(xiàng)目數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
itemNum 指示要在選擇器上顯示的項(xiàng)目數(shù)。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果要在數(shù)字選擇器上顯示的項(xiàng)目數(shù)量小于或等于 0,則引發(fā)此異常。

Since:

4

setValue

public void setValue(int value)

設(shè)置數(shù)字選擇器上的當(dāng)前值。

如果 value 小于 Picker#getMinValue() 且 Picker#isWheelModeEnabled() 設(shè)置為 false,則當(dāng)前值為 Picker#getMinValue() 獲取的值。

如果 value 小于 Picker#getMinValue() 并且 Picker#isWheelModeEnabled() 設(shè)置為 true,則當(dāng)前值是 Picker#getMaxValue() 獲得的值。

如果 value 大于 Picker#getMaxValue() 且 Picker#isWheelModeEnabled() 設(shè)置為 false,則當(dāng)前值為 Picker#getMaxValue() 獲取的值。

如果 value 大于 Picker#getMaxValue() 并且 Picker#isWheelModeEnabled() 設(shè)置為 true,則當(dāng)前值是 Picker#getMinValue() 獲得的值。

參數(shù):

參數(shù)名稱 參數(shù)描述
value 指示要設(shè)置的當(dāng)前值。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值小于 0,則拋出此異常。

setMaxValue

public void setMaxValue(int maxValue)

設(shè)置數(shù)字選擇器的最大值。

參數(shù):

參數(shù)名稱 參數(shù)描述
maxValue 表示要設(shè)置的最大值。 該值必須大于或等于 0。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值小于 0,則拋出此異常。

setMinValue

public void setMinValue(int minValue)

設(shè)置數(shù)字選擇器的最小值。

參數(shù):

參數(shù)名稱 參數(shù)描述
minValue 表示要設(shè)置的最小值。 該值必須大于或等于 0。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值小于 0,則拋出此異常。

setNormalTextSize

public void setNormalTextSize(int textSize)

為數(shù)字選擇器上取消選擇的文本設(shè)置字體大小。

參數(shù):

參數(shù)名稱 參數(shù)描述
textSize 指示取消選擇文本的字體大小。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值不是正數(shù),則引發(fā)此異常。

setSelectedTextSize

public void setSelectedTextSize(int textSize)

為數(shù)字選擇器上的選定文本設(shè)置字體大小。

參數(shù):

參數(shù)名稱 參數(shù)描述
textSize 指示所選文本的字體大小。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值不是正數(shù),則引發(fā)此異常。

setNormalTextColor

public void setNormalTextColor(Color color)

為數(shù)字選擇器上取消選擇的文本設(shè)置顏色。

參數(shù):

參數(shù)名稱 參數(shù)描述
color 指示取消選擇文本的顏色。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值為 null,則引發(fā)此異常。

setSelectedTextColor

public void setSelectedTextColor(Color color)

為數(shù)字選擇器上的選定文本設(shè)置顏色。

參數(shù):

參數(shù)名稱 參數(shù)描述
color 指示所選文本的顏色。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值為 null,則引發(fā)此異常。

setNormalTextFont

public void setNormalTextFont(Font font)

設(shè)置此選擇器中普通文本的字體。

參數(shù):

參數(shù)名稱 參數(shù)描述
font 指示要設(shè)置的字體。

Since:

4

getNormalTextFont

public Font getNormalTextFont()

獲取此選取器中普通文本的字體。

返回:

返回字體。

Since:

4

setSelectedTextFont

public void setSelectedTextFont(Font font)

設(shè)置此選取器中選定文本的字體。

參數(shù):

參數(shù)名稱 參數(shù)描述
font 指示要設(shè)置的字體。

Since:

4

getSelectedTextFont

public Font getSelectedTextFont()

獲取此選取器中選定文本的字體。

返回:

返回所選文本的字體。

Since:

4

setSelectedNormalTextMarginRatio

public void setSelectedNormalTextMarginRatio(float textMarginRatio)

在此數(shù)字選擇器中設(shè)置所選文本邊距與正常文本邊距的比率。

參數(shù):

參數(shù)名稱 參數(shù)描述
textMarginRatio 表示要設(shè)置的比率。 該值必須大于或等于 0.0f。 默認(rèn)值為 1.0f。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值小于 0.0f,則拋出此異常。

setShaderColor

public void setShaderColor(Color color)

為數(shù)字選擇器設(shè)置著色器顏色。

參數(shù):

參數(shù)名稱 參數(shù)描述
color 指示數(shù)字選擇器的著色器顏色。

Throws:

Throw名稱 Throw描述
IllegalArgumentException 如果參數(shù)值為 null,則引發(fā)此異常。

setWheelModeEnabled

public boolean setWheelModeEnabled(boolean isEnabled)

設(shè)置Selector Wheel模式,該模式確定Picker#GetMinvalue()和Picker#getMaxValue()的值是否在最大范圍內(nèi)滾動(dòng)滾動(dòng)時(shí)彼此相鄰顯示。

默認(rèn)情況下,如果最大值和最小值之間的數(shù)字的數(shù)量小于選擇器上可以顯示的數(shù)字的總數(shù),則在滾動(dòng)選擇器時(shí),最大值和最小值并排顯示 它的最大程度。

參數(shù):

參數(shù)名稱 參數(shù)描述
isEnabled 指示是否啟用選擇輪模式。

返回:

如果啟用了選擇輪模式,則返回 true; 否則返回 false。

Since:

4

setDisplayedData

public void setDisplayedData(String[] displayedData)

設(shè)置要顯示的字符串?dāng)?shù)組。

該方法可以使不能直接顯示數(shù)字的控件以字符串的形式顯示數(shù)字。 字符串的長(zhǎng)度必須等于取值范圍內(nèi)取值的總數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
displayedData 表示要顯示的字符串?dāng)?shù)組。

Since:

4

setFormatter

public void setFormatter(Picker.Formatter formatter)

設(shè)置格式化程序以標(biāo)準(zhǔn)化顯示的內(nèi)容。

如果您設(shè)置了數(shù)字以字符串的形式顯示,格式化程序?qū)⒉粫?huì)生效。

參數(shù):

參數(shù)名稱 參數(shù)描述
formatter 表示格式化程序。

getFormatter

public Picker.Formatter getFormatter()

獲取格式化顯示內(nèi)容的格式化程序。

返回:

返回格式化程序。

Since:

4

setDisplayedLinesElements

public void setDisplayedLinesElements(Element top, Element bottom)

設(shè)置用于為選定文本繪制分割線的 Element 實(shí)例。

參數(shù):

參數(shù)名稱 參數(shù)描述
top 指示用于在選定文本頂部繪制分割線的 Element 實(shí)例。
bottom 指示用于在選定文本底部繪制分割線的 Element 實(shí)例。

getDisplayedLinesElements

public Element[] getDisplayedLinesElements()

獲取用于在選定文本的頂部和底部繪制顯示線條的 Element 實(shí)例。

返回:

返回元素實(shí)例。

Since:

4

setDisplayedLinesTopElement

public void setDisplayedLinesTopElement(Element top)

設(shè)置一個(gè) Element 實(shí)例,用于在選定文本的頂部繪制一條顯示線。

參數(shù):

參數(shù)名稱 參數(shù)描述
top 指示要設(shè)置的 Element 實(shí)例。

Since:

4

setDisplayedLinesBottomElement

public void setDisplayedLinesBottomElement(Element bottom)

設(shè)置一個(gè) Element 實(shí)例,用于在選定文本的底部繪制一條顯示線。

參數(shù):

參數(shù)名稱 參數(shù)描述
bottom 指示要設(shè)置的 Element 實(shí)例。

Since:

4

setElementFormatter

public void setElementFormatter(Picker.ElementFormatter formatter)

設(shè)置格式化程序以格式化顯示在每個(gè)項(xiàng)目的左側(cè)和右側(cè)的元素內(nèi)容。

參數(shù):

參數(shù)名稱 參數(shù)描述
formatter 表示格式化程序。

getElementFormatter

public Picker.ElementFormatter getElementFormatter()

獲取每個(gè)項(xiàng)目左右顯示的Element的格式化程序。

返回:

返回格式化程序。

Since:

4

setSelectedTextBackground

public void setSelectedTextBackground(Element element)

將元素設(shè)置為此選擇器選擇的文本的背景。

參數(shù):

參數(shù)名稱 參數(shù)描述
element 指示要設(shè)置的元素。

Since:

4

getSelectedTextBackgroundElement

public Element getSelectedTextBackgroundElement()

獲取元素集作為此選擇器選擇的文本的背景。

返回:

返回元素。

Since:

4

setCompoundElementPadding

public void setCompoundElementPadding(int padding)

設(shè)置文本和元素對(duì)象之間的填充。

參數(shù):

參數(shù)名稱 參數(shù)描述
padding 指示文本和元素對(duì)象之間的填充。

setValueChangedListener

public void setValueChangedListener(Picker.ValueChangedListener valueChangedListener)

設(shè)置數(shù)字選擇器的值更改偵聽(tīng)器。

參數(shù):

參數(shù)名稱 參數(shù)描述
valueChangedListener 表示選取器的值變化監(jiān)聽(tīng)器。

getValueChangedListener

public Picker.ValueChangedListener getValueChangedListener()

獲取監(jiān)聽(tīng)picker值變化的監(jiān)聽(tīng)器。

返回:

返回監(jiān)聽(tīng)器。

Since:

4

setScrollListener

public void setScrollListener(Picker.ScrolledListener scrollListener)

設(shè)置選擇器的滾動(dòng)狀態(tài)偵聽(tīng)器。

參數(shù):

參數(shù)名稱 參數(shù)描述
scrollListener 表示數(shù)字選擇器的滾動(dòng)狀態(tài)監(jiān)聽(tīng)器。

getScrollListener

public Picker.ScrolledListener getScrollListener()

獲取監(jiān)聽(tīng)picker滾動(dòng)狀態(tài)的監(jiān)聽(tīng)器。

返回:

返回監(jiān)聽(tīng)器。

Since:

4

getSelectorItemNum

public int getSelectorItemNum()

獲取選擇輪上顯示的項(xiàng)目數(shù)。

返回:

返回選擇輪上顯示的項(xiàng)目數(shù)。 默認(rèn)值為 0。

Since:

4

getValue

public int getValue()

獲取數(shù)字選擇器上顯示的值。

返回:

返回?cái)?shù)字選擇器上顯示的值。 默認(rèn)值為 1。

getMaxValue

public int getMaxValue()

獲取數(shù)字選擇器的最大值。

返回:

返回?cái)?shù)字選擇器的最大值。 默認(rèn)值為 9。

getMinValue

public int getMinValue()

獲取數(shù)字選擇器的最小值。

返回:

返回?cái)?shù)字選擇器的最小值。 默認(rèn)值為 0。

getNormalTextSize

public int getNormalTextSize()

獲取數(shù)字選擇器上取消選擇的文本的字體大小。

返回:

返回?cái)?shù)字選擇器上取消選擇的文本的字體大小。

getSelectedTextSize

public int getSelectedTextSize()

獲取數(shù)字選擇器上選定文本的字體大小。

返回:

返回?cái)?shù)字選擇器上選定文本的字體大小。

getNormalTextColor

public Color getNormalTextColor()

獲取數(shù)字選擇器上取消選擇的文本的顏色。

返回:

返回?cái)?shù)字選擇器上取消選擇的文本的顏色。

getSelectedTextColor

public Color getSelectedTextColor()

獲取數(shù)字選擇器上選定文本的顏色。

返回:

返回?cái)?shù)字選擇器上選定文本的顏色。

getSelectedNormalTextMarginRatio

public float getSelectedNormalTextMarginRatio()

獲取此數(shù)字選擇器中所選文本邊距與正常文本邊距的比率。

返回:

返回比率。

getShaderColor

public Color getShaderColor()

獲取數(shù)字選擇器的著色器顏色。

返回:

返回?cái)?shù)字選擇器的著色器顏色。

isWheelModeEnabled

public boolean isWheelModeEnabled()

獲取數(shù)字選擇器的選擇器包裝模式。

如果啟用了選擇器環(huán)繞模式,則最大值和最小值會(huì)在選擇輪上彼此相鄰顯示。

返回:

如果啟用了選擇器包裝模式,則返回 true; 否則返回 false。

Since:

4

getDisplayedData

public String[] getDisplayedData()

獲取與要顯示的數(shù)字匹配的字符串?dāng)?shù)組。

該方法可以獲取每個(gè)數(shù)字設(shè)置為字符串顯示后的所有字符串。

返回:

返回與數(shù)字匹配的字符串?dāng)?shù)組。

Since:

4

getDisplayedTopElement

public Element getDisplayedTopElement()

獲取用于在選定數(shù)字頂部繪制分割線的 Element 實(shí)例。

返回:

返回用于在所選數(shù)字頂部繪制分割線的 Element 實(shí)例。

getDisplayedBottomElement

public Element getDisplayedBottomElement()

獲取用于在選定數(shù)字底部繪制分割線的 Element 實(shí)例。

返回:

返回用于在所選數(shù)字底部繪制分割線的 Element 實(shí)例。

getCompoundElementPadding

public int getCompoundElementPadding()

獲取文本和 Element 對(duì)象之間的填充。

返回:

返回文本和元素對(duì)象之間的填充。

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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)