鴻蒙OS ProgressBar

2022-09-28 13:43 更新

ProgressBar

java.lang.Object

|---ohos.agp.components.Component

|---|---ohos.agp.components.ProgressBar

  1. public class ProgressBar
  2. extends Component

提供用于指示 UI 上操作的進(jìn)度的元素。

進(jìn)度條支持確定類型和不確定類型。 進(jìn)度條顯示在 UI 或通知中,不會打擾用戶。

不確定的進(jìn)展

當(dāng)操作所需的時間不確定時,使用不確定的進(jìn)度條。

確定進(jìn)度

當(dāng)您需要顯示操作的具體進(jìn)度量時,使用確定進(jìn)度條。 您可以使用 setProgressValue(int) 函數(shù)來更新當(dāng)前進(jìn)度。 默認(rèn)情況下,當(dāng)進(jìn)度條上顯示的進(jìn)度值達(dá)到 100 時,操作完成。

Since:

1

嵌套類摘要

修飾符和類型 描述
static interface ProgressBar.BarObserver 提供一個文本觀察器來監(jiān)聽組件中進(jìn)度條的變化。
從類 ohos.agp.components.Component 繼承的嵌套類/接口
Component.BindStateChangedListener, Component.CanAcceptScrollListener, Component.ClickedListener, Component.ComponentStateChangedListener, Component.ContourRefreshedListener, Component.DefSpeechEventListener, Component.DoubleClickedListener, Component.DragFeedbackProvider, Component.DraggedListener, Component.DrawTask, Component.EditEventListener, Component.EstimateSizeListener, Component.EstimateSpec, Component.FadeEffectEnum, Component.FocusChangedListener, Component.ForwardHoverListener, Component.ForwardTouchListener, Component.GestureType, Component.HoverEventListener, Component.KeyEventListener, Component.LayoutDirection, Component.LayoutRefreshedListener, Component.LongClickedListener, Component.MeasureSpec, Component.MouseEventListener, Component.MousePointerStyleListener, Component.OnDragListener, Component.RotationEventListener, Component.ScaledListener, Component.ScrolledListener, Component.ShadowDevice, Component.ShadowMode, Component.ShadowSize, Component.SpeechEventListener, Component.TouchEventListener, Component.UnconsumedKeyEventListener, Component.VoiceEvent

字段摘要

從類 ohos.agp.components.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

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

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

方法總結(jié)

修飾符和類型 方法 描述
void addBarObserver(ProgressBar.BarObserver observer) 添加一個 BarObserver 來監(jiān)控這個進(jìn)度條的變化。
void enableDividerLines(boolean enable) 設(shè)置進(jìn)度條的分隔符狀態(tài)。
Element getBackgroundInstructElement() 獲取用作進(jìn)度條背景的 Element 對象。
Color getDividerLineColor() 獲取分隔線顏色。
int getDividerLinesNumber() 獲取此進(jìn)度條的分隔線數(shù)。
int getDividerLineThickness() 獲取分隔線粗細(xì)。
Element getInfiniteModeElement() 獲取用于繪制不確定進(jìn)度條的元素對象。
int getMax() 獲取確定進(jìn)度條的上限。
int getMaxHeight() 獲取進(jìn)度條的最大高度。
int getMaxWidth() 獲取進(jìn)度條的最大寬度。
int getMin() 獲取確定進(jìn)度條的下限。
int getOrientation() 獲取進(jìn)度條方向。
int getProgress() 獲取進(jìn)度條的當(dāng)前進(jìn)度值。
Color getProgressColor() 獲取此進(jìn)度條的顏色。
int[] getProgressColors() 獲取用于繪制此進(jìn)度條的 ShapeElement 對象的填充顏色。
Element getProgressElement() 獲取用作進(jìn)度條的 Element 對象。
String getProgressHintText() 獲取進(jìn)度條上的提示文本。
int getProgressHintTextAlignment() 獲取進(jìn)度條上的提示文本對齊方式。
Color getProgressHintTextColor() 獲取進(jìn)度條上的提示文本顏色。
int getProgressHintTextSize() 獲取此進(jìn)度條上提示文本的大小。
int getProgressWidth() 獲取此進(jìn)度條的最大寬度。
int getStep() 獲取進(jìn)度條的進(jìn)度步驟。
Element getViceProgressElement() 獲取用作副進(jìn)度條的 Element 對象。
int getViceProgressValue() 獲取進(jìn)度條的二級進(jìn)度值。
boolean isDividerLinesEnabled() 檢查是否啟用了分隔線。
boolean isIndeterminate() 檢查是否啟用了不確定模式。
boolean isInfiniteMode() 檢查是否為進(jìn)度條啟用了不確定模式。
void removeBarObserver(ProgressBar.BarObserver observer) 移除此進(jìn)度條的 BarObserver。
void setDividerLineColor(Color color) 設(shè)置分隔線顏色。
void setDividerLinesNumber(int number) 設(shè)置此進(jìn)度條的分隔線數(shù)量。
void setDividerLineThickness(int thickness) 設(shè)置分隔線粗細(xì)。
void setIndeterminate(boolean indeterminate) 設(shè)置是否為進(jìn)度條啟用不確定模式。
void setInfiniteModeElement(Element element) 設(shè)置用于繪制不確定進(jìn)度條的元素對象。
void setMaxHeight(int maxHeight) 設(shè)置進(jìn)度條的最大高度。
void setMaxValue(int max) 設(shè)置進(jìn)度條的上限。
void setMaxWidth(int maxWidth) 設(shè)置進(jìn)度條的最大寬度。
void setMinValue(int min) 設(shè)置進(jìn)度條的下限。
void setOrientation(int orientation) 設(shè)置進(jìn)度條方向。
void setProgressBackgroundElement(Element element) 將 Element 對象設(shè)置為進(jìn)度條的背景。
void setProgressColor(Color color) 設(shè)置此進(jìn)度條的顏色。
void setProgressColors(int[] colors) 設(shè)置此進(jìn)度條的漸變效果的顏色。
void setProgressElement(Element element) 將 Element 對象設(shè)置為進(jìn)度條。
void setProgressHintText(String text) 設(shè)置進(jìn)度條的提示文本。
void setProgressHintTextAlignment(int alignment) 在進(jìn)度條上設(shè)置提示文本對齊模式。
void setProgressHintTextColor(Color color) 在進(jìn)度條上設(shè)置提示文本顏色。
void setProgressHintTextSize(int size) 設(shè)置此進(jìn)度條上提示文本的大小。
void setProgressValue(int progress) 設(shè)置進(jìn)度條的當(dāng)前進(jìn)度。
void setProgressWidth(int progressWidth) 設(shè)置此進(jìn)度條的最大寬度。
void setStep(int step) 設(shè)置進(jìn)度步驟。
void setViceProgress(int progress) 設(shè)置進(jìn)度條的次要進(jìn)度值。
void setViceProgressElement(Element element) 將 Element 對象設(shè)置為副進(jìn)度條。
從類 ohos.agp.components.Component 繼承的方法
addDrawTask, addDrawTask, addScrolledListener, announceAccessibility, arrange, bindCornerMark, callOnClick, canScroll, clearFocus, createAnimatorProperty, disableFadeEffect, dispatchRestoreState, dispatchSaveState, draw, enableCornerMark, enableFadeEffect, enableSaveState, enableScrollBar, estimateSize, executeDoubleClick, executeLongClick, findComponentById, findComponentHolderById, 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, informConfigurationChanged, invalidate, isBoundaryFadeEffectEnable, isBoundToWindow, isClickable, isClipToContourEnabled, isComponentDisplayed, isEnabled, isFadeEffected, isFocusable, isFocused, isIdentityMatrix, isLongClickOn, isPressed, isRtl, isSaveStateEnabled, isScrollbarFadingOn, isScrollBarOn, isScrollbarOverlapEnabled, isSelected, isSoundEnable, isTouchFocusable, isVibrationEffectEnabled, notifyAccessibility, onAttributeConfigChanged, onDrag, 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
從類 java.lang.Object 繼承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

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

ProgressBar

public ProgressBar(Context context)

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

參數(shù):

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

ProgressBar

public ProgressBar(Context context, AttrSet attrSet)

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

參數(shù):

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

ProgressBar

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

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

參數(shù):

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

方法詳情

setOrientation

public void setOrientation(int orientation)

設(shè)置進(jìn)度條方向。

參數(shù):

參數(shù)名稱 參數(shù)描述
orientation 指示進(jìn)度條方向,可以是 Component.HORIZONTAL 或 Component.VERTICAL。

Since:

2

getOrientation

public int getOrientation()

獲取進(jìn)度條方向。

返回:

返回進(jìn)度條方向,可以是 Component.HORIZONTAL 或 Component.VERTICAL。

Since:

2

setMinValue

public void setMinValue(int min)

設(shè)置進(jìn)度條的下限。

此方法在實(shí)際進(jìn)度小于下限時顯示進(jìn)度條的下限。

參數(shù):

參數(shù)名稱 參數(shù)描述
min 指示進(jìn)度條的下限。

Since:

4

setMaxValue

public void setMaxValue(int max)

設(shè)置進(jìn)度條的上限。

當(dāng)實(shí)際進(jìn)度大于上限時,該方法在進(jìn)度條上顯示上限。

參數(shù):

參數(shù)名稱 參數(shù)描述
max 表示進(jìn)度條的上限。

Since:

4

setProgressValue

public void setProgressValue(int progress)

設(shè)置進(jìn)度條的當(dāng)前進(jìn)度。

此方法立即更新進(jìn)度指示器。

參數(shù):

參數(shù)名稱 參數(shù)描述
progress 指示 getMin() 和 getMax() 之間的進(jìn)度值。

Since:

4

setViceProgress

public void setViceProgress(int progress)

設(shè)置進(jìn)度條的次要進(jìn)度值。

參數(shù):

參數(shù)名稱 參數(shù)描述
progress 表示二級進(jìn)度值,必須在getMin()和getMax()的范圍內(nèi)。

Since:

4

setStep

public void setStep(int step)

設(shè)置進(jìn)度步驟。

此方法設(shè)置增加或減少進(jìn)度值的步驟。 默認(rèn)值為 1。如果步長為 10,則進(jìn)度值為 10 的倍數(shù)。

參數(shù):

參數(shù)名稱 參數(shù)描述
step 指示進(jìn)度步驟。

Since:

1

setIndeterminate

public void setIndeterminate(boolean indeterminate)

設(shè)置是否為進(jìn)度條啟用不確定模式。

如果禁用不確定模式,將顯示進(jìn)度值。 如果啟用了不確定模式,則會顯示無限循環(huán)的動畫。

參數(shù):

參數(shù)名稱 參數(shù)描述
indeterminate 指示是否為進(jìn)度條啟用不確定模式。 true 表示啟用不確定模式; false 表示其他情況。

Since:

1

isIndeterminate

public boolean isIndeterminate()

檢查是否啟用了不確定模式。

返回:

如果啟用了不確定模式,則返回 true; 否則返回 false。

Since:

3

setInfiniteModeElement

public void setInfiniteModeElement(Element element)

設(shè)置用于繪制不確定進(jìn)度條的元素對象。

元素對象圍繞其中心重復(fù)順時針旋轉(zhuǎn)。

參數(shù):

參數(shù)名稱 參數(shù)描述
element 表示元素對象。

Since:

4

setMaxWidth

public void setMaxWidth(int maxWidth)

設(shè)置進(jìn)度條的最大寬度。

如果父布局提供的寬度大于最大寬度,則使用最大寬度進(jìn)行繪制。

參數(shù):

參數(shù)名稱 參數(shù)描述
maxWidth 指示進(jìn)度條的最大寬度。

Since:

1

setMaxHeight

public void setMaxHeight(int maxHeight)

設(shè)置進(jìn)度條的最大高度。

如果父布局提供的高度大于最大高度,則使用最大高度繪制進(jìn)度條。

參數(shù):

參數(shù)名稱 參數(shù)描述
maxHeight 表示最大高度。

Since:

1

getInfiniteModeElement

public Element getInfiniteModeElement()

獲取用于繪制不確定進(jìn)度條的元素對象。

元素對象圍繞其中心重復(fù)順時針旋轉(zhuǎn)。

返回:

返回元素對象。

Since:

4

getMin

public int getMin()

獲取確定進(jìn)度條的下限。

默認(rèn)情況下,下限為 0。

返回:

返回確定進(jìn)度條的下限,為 0 或正整數(shù)。

Since:

1

getMax

public int getMax()

獲取確定進(jìn)度條的上限。

默認(rèn)情況下,上限為 100。

返回:

返回確定進(jìn)度條的上限,為正整數(shù)。

Since:

1

getProgress

public int getProgress()

獲取進(jìn)度條的當(dāng)前進(jìn)度值。

該方法獲取確定進(jìn)度條的當(dāng)前進(jìn)度值。 默認(rèn)情況下,初始值設(shè)置為下限。

返回:

返回進(jìn)度值,它是一個整數(shù)。

Since:

1

getViceProgressValue

public int getViceProgressValue()

獲取進(jìn)度條的二級進(jìn)度值。

返回:

返回進(jìn)度條的二級進(jìn)度值。

Since:

4

getStep

public int getStep()

獲取進(jìn)度條的進(jìn)度步驟。

進(jìn)度值只能是進(jìn)度步長的倍數(shù)。 進(jìn)度步默認(rèn)設(shè)置為 1。

返回:

返回進(jìn)度條的進(jìn)度步長,為正整數(shù)。

Since:

1

isInfiniteMode

public boolean isInfiniteMode()

檢查是否為進(jìn)度條啟用了不確定模式。

確定模式是指在進(jìn)度條上顯示一定的進(jìn)度值來顯示當(dāng)前的進(jìn)度。 不確定模式表示進(jìn)度值不可用,并顯示一個圍繞其中心順時針重復(fù)旋轉(zhuǎn)的元素對象,以顯示操作的進(jìn)行狀態(tài)。

返回:

如果為進(jìn)度條啟用了不確定模式,則返回 true; 否則返回 false。

Since:

4

getMaxWidth

public int getMaxWidth()

獲取進(jìn)度條的最大寬度。

此方法將進(jìn)度條的最大寬度與父組件提供的最大寬度進(jìn)行比較。 如果父組件提供的寬度超過最大寬度,進(jìn)度條將使用其最大寬度繪制。

返回:

返回進(jìn)度條的最大寬度。

Since:

1

getMaxHeight

public int getMaxHeight()

獲取進(jìn)度條的最大高度。

此方法將進(jìn)度條的最大高度與父組件提供的高度進(jìn)行比較。 如果父組件提供的高度超過最大高度,進(jìn)度條將使用其最大高度繪制。

返回:

返回進(jìn)度條的最大高度。

Since:

1

setProgressBackgroundElement

public void setProgressBackgroundElement(Element element)

將 Element 對象設(shè)置為進(jìn)度條的背景。

參數(shù):

參數(shù)名稱 參數(shù)描述
element 指示用作進(jìn)度條背景的 Element 對象。

Since:

2

setProgressElement

public void setProgressElement(Element element)

將 Element 對象設(shè)置為進(jìn)度條。

參數(shù):

參數(shù)名稱 參數(shù)描述
element 指示用作進(jìn)度條的 Element 對象。

Since:

2

setViceProgressElement

public void setViceProgressElement(Element element)

將 Element 對象設(shè)置為副進(jìn)度條。

參數(shù):

參數(shù)名稱 參數(shù)描述
element 指示用作副進(jìn)度條的 Element 對象。

Since:

4

getBackgroundInstructElement

public Element getBackgroundInstructElement()

獲取用作進(jìn)度條背景的 Element 對象。

返回:

返回用作進(jìn)度條背景的 Element 對象。

Since:

4

getProgressElement

public Element getProgressElement()

獲取用作進(jìn)度條的 Element 對象。

返回:

返回用作進(jìn)度條的 Element 對象。

Since:

2

getViceProgressElement

public Element getViceProgressElement()

獲取用作副進(jìn)度條的 Element 對象。

返回:

返回用作副進(jìn)度條的 Element 對象。

Since:

4

getProgressHintText

public String getProgressHintText()

獲取進(jìn)度條上的提示文本。

返回:

返回進(jìn)度條上的提示文本。

Since:

2

setProgressHintText

public void setProgressHintText(String text)

設(shè)置進(jìn)度條的提示文本。

參數(shù):

參數(shù)名稱 參數(shù)描述
text 表示進(jìn)度條的提示文字。

Since:

2

setProgressHintTextSize

public void setProgressHintTextSize(int size)

設(shè)置此進(jìn)度條上提示文本的大小。

參數(shù):

參數(shù)名稱 參數(shù)描述
size 指示要設(shè)置的大小,以像素為單位。

Since:

4

getProgressHintTextSize

public int getProgressHintTextSize()

獲取此進(jìn)度條上提示文本的大小。

返回:

返回提示文本大小,以像素為單位。

Since:

4

setProgressHintTextColor

public void setProgressHintTextColor(Color color)

在進(jìn)度條上設(shè)置提示文本顏色。

參數(shù):

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

Since:

2

getProgressHintTextColor

public Color getProgressHintTextColor()

獲取進(jìn)度條上的提示文本顏色。

返回:

返回提示文本顏色。

Since:

2

setProgressHintTextAlignment

public void setProgressHintTextAlignment(int alignment)

在進(jìn)度條上設(shè)置提示文本對齊模式。

參數(shù):

參數(shù)名稱 參數(shù)描述
alignment 指示提示文本對齊方式。

Since:

2

getProgressHintTextAlignment

public int getProgressHintTextAlignment()

獲取進(jìn)度條上的提示文本對齊方式。

返回:

返回提示文本對齊模式。

Since:

2

enableDividerLines

public void enableDividerLines(boolean enable)

設(shè)置進(jìn)度條的分隔符狀態(tài)。

此方法啟用或禁用進(jìn)度條的分隔線。

參數(shù):

參數(shù)名稱 參數(shù)描述
enable 指示是否啟用分隔符。 enable 表示啟用分頻器; disable 表示禁用。

Since:

3

isDividerLinesEnabled

public boolean isDividerLinesEnabled()

檢查是否啟用了分隔線。

返回:

如果啟用了分隔線,則返回 true; 否則返回 false。

Since:

3

setDividerLinesNumber

public void setDividerLinesNumber(int number)

設(shè)置此進(jìn)度條的分隔線數(shù)量。

參數(shù):

參數(shù)名稱 參數(shù)描述
number 指示要設(shè)置的分隔符數(shù)量。

Since:

3

getDividerLinesNumber

public int getDividerLinesNumber()

獲取此進(jìn)度條的分隔線數(shù)。

返回:

返回分頻器的數(shù)量。

Since:

3

setDividerLineThickness

public void setDividerLineThickness(int thickness)

設(shè)置分隔線粗細(xì)。

參數(shù):

參數(shù)名稱 參數(shù)描述
thickness 指示分隔線粗細(xì)。

Since:

3

getDividerLineThickness

public int getDividerLineThickness()

獲取分隔線粗細(xì)。

返回:

返回分隔線粗細(xì)。

Since:

3

setDividerLineColor

public void setDividerLineColor(Color color)

設(shè)置分隔線顏色。

參數(shù):

參數(shù)名稱 參數(shù)描述
color Indicates the divider line color.

Since:

3

getDividerLineColor

public Color getDividerLineColor()

獲取分隔線顏色。

返回:

返回分隔線顏色。

Since:

3

setProgressWidth

public void setProgressWidth(int progressWidth)

設(shè)置此進(jìn)度條的最大寬度。

將使用其寬度繪制進(jìn)度條。

參數(shù):

參數(shù)名稱 參數(shù)描述
progressWidth 指示要設(shè)置的最大寬度。

Since:

3

getProgressWidth

public int getProgressWidth()

獲取此進(jìn)度條的最大寬度。

將使用其寬度繪制進(jìn)度條。

返回:

返回最大寬度。

Since:

3

setProgressColor

public void setProgressColor(Color color)

設(shè)置此進(jìn)度條的顏色。

參數(shù):

參數(shù)名稱 參數(shù)描述
color 指示要設(shè)置的顏色。

Since:

3

getProgressColor

public Color getProgressColor()

獲取此進(jìn)度條的顏色。

返回:

返回顏色。

Since:

3

setProgressColors

public void setProgressColors(int[] colors)

設(shè)置此進(jìn)度條的漸變效果的顏色。

參數(shù):

參數(shù)名稱 參數(shù)描述
colors 指示要設(shè)置的顏色。

Since:

3

getProgressColors

public int[] getProgressColors()

獲取用于繪制此進(jìn)度條的 ShapeElement 對象的填充顏色。

返回:

如果可用,則返回填充顏色數(shù)組; 如果使用純色,則返回一個只有一個元素的數(shù)組。

Since:

3

addBarObserver

public void addBarObserver(ProgressBar.BarObserver observer)

添加一個 BarObserver 來監(jiān)控這個進(jìn)度條的變化。

在使用 BarObserver 之前,您必須實(shí)現(xiàn) BarObserver#onBarChanged。

參數(shù):

參數(shù)名稱 參數(shù)描述
observer 指示要添加的條形觀察者。

Since:

4

removeBarObserver

public void removeBarObserver(ProgressBar.BarObserver observer)

移除此進(jìn)度條的 BarObserver。

參數(shù):

參數(shù)名稱 參數(shù)描述
observer 指示要刪除的條形觀察者。

Since:

4

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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號