AbsSlider, RoundProgressBarpublic class ProgressBar extends Component
The progress bar supports the determinate and indeterminate types. The progress bar is displayed on a UI or in a notification without interrupting users.
The indeterminate progress bar is used when the time required for the operation is uncertain.
The determinate progress bar is used when you need to display the specific quantity of progress of the operation.
You can use the setProgressValue(int) function to update the current progress.
By default, when the progress value displayed on the progress bar reaches 100, the operation is complete.
| 限定符和类型 | 类 | 说明 |
|---|---|---|
static interface |
ProgressBar.BarObserver |
Provides a text observer to listen for changes of progress bars in a 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.VoiceEventACCESSIBILITY_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| 构造器 | 说明 |
|---|---|
ProgressBar(Context context) |
Default constructor used to create a
ProgressBar instance by using the default attribute set and style. |
ProgressBar(Context context,
AttrSet attrSet) |
A constructor used to create a
ProgressBar instance by using specified attribute set and default
style after the XML file is parsed. |
ProgressBar(Context context,
AttrSet attrSet,
String styleName) |
A constructor used to create a
ProgressBar instance by using specified attribute set and specified
style after the XML file is parsed. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
addBarObserver(ProgressBar.BarObserver observer) |
Adds a
BarObserver to monitor changes of this progress bar. |
void |
enableDividerLines(boolean enable) |
Sets dividers state for a progress bar.
|
Element |
getBackgroundInstructElement() |
Obtains the
Element object used as the background of a progress bar. |
Color |
getDividerLineColor() |
Obtains the divider line color.
|
int |
getDividerLinesNumber() |
Obtains the number of dividers for this progress bar.
|
int |
getDividerLineThickness() |
Obtains the divider line thickness.
|
Element |
getInfiniteModeElement() |
Obtains the element object used to draw an indeterminate progress bar.
|
int |
getMax() |
Obtains the upper limit of a determinate progress bar.
|
int |
getMaxHeight() |
Obtains the maximum height of the progress bar.
|
int |
getMaxWidth() |
Obtains the maximum width of a progress bar.
|
int |
getMin() |
Obtains the lower limit of a determinate progress bar.
|
int |
getOrientation() |
Obtains the progress bar direction.
|
int |
getProgress() |
Obtains the current progress value of the progress bar.
|
Color |
getProgressColor() |
Obtains the color of this progress bar.
|
int[] |
getProgressColors() |
Obtains fill colors of the
ShapeElement object used to draw this progress bar. |
Element |
getProgressElement() |
Obtains the
Element object used as a progress bar. |
String |
getProgressHintText() |
Obtains the hint text on a progress bar.
|
int |
getProgressHintTextAlignment() |
Obtains the hint text alignment mode on a progress bar.
|
Color |
getProgressHintTextColor() |
Obtains the hint text color on a progress bar.
|
int |
getProgressHintTextSize() |
Obtains the size of the hint text on this progress bar.
|
int |
getProgressWidth() |
Obtains the maximum width of this progress bar.
|
int |
getStep() |
Obtains the progress step of a progress bar.
|
Element |
getViceProgressElement() |
Obtains the
Element object used as a vice progress bar. |
int |
getViceProgressValue() |
Obtains the secondary progress value of a progress bar.
|
boolean |
isDividerLinesEnabled() |
Checks whether the divider lines are enabled.
|
boolean |
isIndeterminate() |
Checks whether the indeterminate mode is enabled.
|
boolean |
isInfiniteMode() |
Checks if the indeterminate mode is enabled for a progress bar.
|
void |
removeBarObserver(ProgressBar.BarObserver observer) |
Removes the
BarObserver of this progress bar. |
void |
setDividerLineColor(Color color) |
Sets the divider line color.
|
void |
setDividerLinesNumber(int number) |
Sets the number of dividers for this progress bar.
|
void |
setDividerLineThickness(int thickness) |
Sets the divider line thickness.
|
void |
setIndeterminate(boolean indeterminate) |
Sets whether to enable indeterminate mode for a progress bar.
|
void |
setInfiniteModeElement(Element element) |
Sets the element object used to draw an indeterminate progress bar.
|
void |
setMaxHeight(int maxHeight) |
Sets the maximum height of a progress bar.
|
void |
setMaxValue(int max) |
Sets the upper limit for the progress bar.
|
void |
setMaxWidth(int maxWidth) |
Sets the maximum width of the progress bar.
|
void |
setMinValue(int min) |
Sets the lower limit of a progress bar.
|
void |
setOrientation(int orientation) |
Sets the progress bar direction.
|
void |
setProgressBackgroundElement(Element element) |
Sets a
Element object as the background of a progress bar. |
void |
setProgressColor(Color color) |
Sets the color for this progress bar.
|
void |
setProgressColors(int[] colors) |
Sets colors for the gradient effect of this progress bar.
|
void |
setProgressElement(Element element) |
Sets a
Element object as a progress bar. |
void |
setProgressHintText(String text) |
Sets the hint text of a progress bar.
|
void |
setProgressHintTextAlignment(int alignment) |
Sets the hint text alignment mode on a progress bar.
|
void |
setProgressHintTextColor(Color color) |
sets the hint text color on a progress bar.
|
void |
setProgressHintTextSize(int size) |
Sets the size for the hint text on this progress bar.
|
void |
setProgressValue(int progress) |
Sets the current progress for the progress bar.
|
void |
setProgressWidth(int progressWidth) |
Sets the maximum width for this progress bar.
|
void |
setStep(int step) |
Sets the progress step.
|
void |
setViceProgress(int progress) |
Sets the secondary progress value of a progress bar.
|
void |
setViceProgressElement(Element element) |
Sets a
Element object as a vice progress bar. |
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, unsubscribeVoiceEventspublic ProgressBar(Context context)
ProgressBar instance by using the default attribute set and style.context - Indicates the application context.public ProgressBar(Context context, AttrSet attrSet)
ProgressBar 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 ProgressBar(Context context, AttrSet attrSet, String styleName)
ProgressBar 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 setOrientation(int orientation)
orientation - Indicates the progress bar direction, which can be either Component.HORIZONTAL or
Component.VERTICAL.public int getOrientation()
Component.HORIZONTAL or Component.VERTICAL.public void setMinValue(int min)
This method displays the lower limit of the progress bar when the actual progress is less than the lower limit.
min - Indicates the lower limit of the progress bar.public void setMaxValue(int max)
This method displays the upper limit on the progress bar when the actual progress is greater than the upper limit.
max - Indicates the upper limit of the progress bar.public void setProgressValue(int progress)
This method updates the progress indicator immediately.
public void setViceProgress(int progress)
public void setStep(int step)
This method sets the step for increasing or decreasing the progress value. The default value is 1.
If the step is 10, the progress value is a multiple of 10.
step - Indicates the progress step.public void setIndeterminate(boolean indeterminate)
If the indeterminate mode is disabled, the progress value will be displayed. If the indeterminate mode is enabled, an animation in infinite loop will be displayed.
indeterminate - Indicates whether to enable indeterminate mode for the progress bar. true means
to enable indeterminate mode; false means otherwise.public boolean isIndeterminate()
true if the indeterminate mode is enabled; returns false otherwise.public void setInfiniteModeElement(Element element)
The element object repeats rotating clockwise around its center.
element - Indicates the element object.public void setMaxWidth(int maxWidth)
If the width provided by the parent layout is greater than the maximum width, the maximum width is used for drawing.
maxWidth - Indicates the maximum width of the progress bar.getMaxWidth()public void setMaxHeight(int maxHeight)
If the height provided by the parent layout is greater than the maximum height, the maximum height is used for drawing the progress bar.
maxHeight - Indicates the maximum height.getMaxHeight()public Element getInfiniteModeElement()
The element object repeats rotating clockwise around its center.
public int getMin()
By default, the lower limit is 0.
0 or a positive integer.public int getMax()
By default, the upper limit is 100.
public int getProgress()
This method obtains the current progress value of a determinate progress bar. By default, the initial value is set to the lower limit.
public int getViceProgressValue()
public int getStep()
The progress value can only be a multiple of the progress step. The progress step is set to 1 by
default.
public boolean isInfiniteMode()
The determinate mode indicates that a certain progress value is displayed on the progress bar to show the current progress. The indeterminate mode indicates that the progress value is unavailable, and an element object that repeats rotating clockwise around its center is displayed to show the ongoing status of the operation.
true if indeterminate mode is enabled for the progress bar; returns false
otherwise.public int getMaxWidth()
This method compares the maximum width of the progress bar with that provided by the parent component. If the width provided by the parent component exceeds the maximum width, the progress bar will be drawn using its maximum width.
setMaxWidth(int)public int getMaxHeight()
This method compares the maximum height of the progress bar with that provided by the parent component. If the height provided by the parent component exceeds the maximum height, the progress bar will be drawn using its maximum height.
setMaxHeight(int)public void setProgressBackgroundElement(Element element)
Element object as the background of a progress bar.element - Indicates the Element object used as the background of a progress bar.public void setProgressElement(Element element)
Element object as a progress bar.element - Indicates the Element object used as a progress bar.public void setViceProgressElement(Element element)
Element object as a vice progress bar.element - Indicates the Element object used as a vice progress bar.public Element getBackgroundInstructElement()
Element object used as the background of a progress bar.Element object used as the background of the progress bar.public Element getProgressElement()
Element object used as a progress bar.Element object used as the progress bar.public Element getViceProgressElement()
Element object used as a vice progress bar.Element object used as the vice progress bar.public String getProgressHintText()
public void setProgressHintText(String text)
text - Indicates the hint text of the progress bar.public void setProgressHintTextSize(int size)
size - Indicates the size to set, in pixels.public int getProgressHintTextSize()
public void setProgressHintTextColor(Color color)
color - Indicates the hint text color.public Color getProgressHintTextColor()
public void setProgressHintTextAlignment(int alignment)
alignment - Indicates the hint text alignment mode.TextAlignmentpublic int getProgressHintTextAlignment()
TextAlignmentpublic void enableDividerLines(boolean enable)
This method enables or disables a divider lines of a progress bar.
enable - Indicates whether to enable dividers. enable indicates to enable dividers;
disable indicates to disable.public boolean isDividerLinesEnabled()
true if the divider lines are enabled; returns false otherwise.public void setDividerLinesNumber(int number)
number - Indicates the number of dividers to set.enableDividerLines(boolean)public int getDividerLinesNumber()
enableDividerLines(boolean)public void setDividerLineThickness(int thickness)
thickness - Indicates the divider line thickness.enableDividerLines(boolean)public int getDividerLineThickness()
enableDividerLines(boolean)public void setDividerLineColor(Color color)
color - Indicates the divider line color.enableDividerLines(boolean)public Color getDividerLineColor()
enableDividerLines(boolean)public void setProgressWidth(int progressWidth)
A progress bar will be drawn using its width.
progressWidth - Indicates the maximum width to set.getProgressWidth()public int getProgressWidth()
A progress bar will be drawn using its width.
setProgressWidth(int)public void setProgressColor(Color color)
color - Indicates the color to set.public Color getProgressColor()
public void setProgressColors(int[] colors)
colors - Indicates the colors to set.getProgressColors()public int[] getProgressColors()
ShapeElement object used to draw this progress bar.public void addBarObserver(ProgressBar.BarObserver observer)
BarObserver to monitor changes of this progress bar.
You must implement BarObserver#onBarChanged before using the BarObserver.
observer - Indicates the bar observer to add.public void removeBarObserver(ProgressBar.BarObserver observer)
BarObserver of this progress bar.observer - Indicates the bar observer to remove.addBarObserver(BarObserver)