public class ProgressBar extends View
Visual indicator of progress in some operation. Displays a bar to the user representing how far the operation has progressed; the application can change the amount of progress (modifying the length of the bar) as it moves forward. There is also a secondary progress displayable on a progress bar which is useful for displaying intermediate progress, such as the buffer level during a streaming playback progress bar.
A progress bar can also be made indeterminate. In indeterminate mode, the progress bar shows a cyclic animation without an indication of progress. This mode is used by applications when the length of the task is unknown. The indeterminate progress bar can be either a spinning wheel or a horizontal bar.
The following code example shows how a progress bar can be used from a worker thread to update the user interface to notify the user of progress:
public class MyActivity extends Activity { private static final int PROGRESS = 0x1; private ProgressBar mProgress; private int mProgressStatus = 0; private Handler mHandler = new Handler(); protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.progressbar_activity); mProgress = (ProgressBar) findViewById(R.id.progress_bar); // Start lengthy operation in a background thread new Thread(new Runnable() { public void run() { while (mProgressStatus < 100) { mProgressStatus = doWork(); // Update the progress bar mHandler.post(new Runnable() { public void run() { mProgress.setProgress(mProgressStatus); } }); } } }).start(); } }
To add a progress bar to a layout file, you can use the <ProgressBar>
element.
By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a
horizontal progress bar, apply the Widget.ProgressBar.Horizontal
style, like so:
<ProgressBar style="@android:style/Widget.ProgressBar.Horizontal" ... />
If you will use the progress bar to show real progress, you must use the horizontal bar. You
can then increment the progress with incrementProgressBy()
or
setProgress()
. By default, the progress bar is full when it reaches 100. If
necessary, you can adjust the maximum value (the value for a full bar) using the android:max
attribute. Other attributes available are listed
below.
Another common style to apply to the progress bar is Widget.ProgressBar.Small
, which shows a smaller
version of the spinning wheel—useful when waiting for content to load.
For example, you can insert this kind of progress bar into your default layout for
a view that will be populated by some content fetched from the Internet—the spinning wheel
appears immediately and when your application receives the content, it replaces the progress bar
with the loaded content. For example:
<LinearLayout android:orientation="horizontal" ... > <ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" style="@android:style/Widget.ProgressBar.Small" android:layout_marginRight="5dp" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/loading" /> </LinearLayout>
Other progress bar styles provided by the system include:
Widget.ProgressBar.Horizontal
Widget.ProgressBar.Small
Widget.ProgressBar.Large
Widget.ProgressBar.Inverse
Widget.ProgressBar.Small.Inverse
Widget.ProgressBar.Large.Inverse
The "inverse" styles provide an inverse color scheme for the spinner, which may be necessary if your application uses a light colored theme (a white background).
XML attributes
See ProgressBar Attributes
,
View Attributes
View.AccessibilityDelegate, View.BaseSavedState, View.DragShadowBuilder, View.DrawingCacheQuality, View.FindViewFlags, View.FocusableMode, View.FocusDirection, View.FocusRealDirection, View.LayoutDir, View.MeasureSpec, View.OnApplyWindowInsetsListener, View.OnAttachStateChangeListener, View.OnClickListener, View.OnContextClickListener, View.OnCreateContextMenuListener, View.OnDragListener, View.OnFocusChangeListener, View.OnGenericMotionListener, View.OnHoverListener, View.OnKeyListener, View.OnLayoutChangeListener, View.OnLongClickListener, View.OnScrollChangeListener, View.OnSystemUiVisibilityChangeListener, View.OnTouchListener, View.ResolvedLayoutDir, View.ScrollBarStyle, View.ScrollIndicators, View.TextAlignment, View.Visibility
ACCESSIBILITY_CURSOR_POSITION_UNDEFINED, ACCESSIBILITY_LIVE_REGION_ASSERTIVE, ACCESSIBILITY_LIVE_REGION_NONE, ACCESSIBILITY_LIVE_REGION_POLITE, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION, DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION, DRAG_FLAG_GLOBAL_URI_READ, DRAG_FLAG_GLOBAL_URI_WRITE, DRAG_FLAG_OPAQUE, 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_ACCESSIBILITY_NODE_PROVIDERS, 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, LAYOUT_DIRECTION_UNDEFINED, mAttributes, mBottom, mCachingFailed, mContext, mCurrentAnimation, mDebugViewAttributes, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NAVIGATION_BAR_TRANSIENT, NAVIGATION_BAR_TRANSLUCENT, NAVIGATION_BAR_TRANSPARENT, NAVIGATION_BAR_UNHIDE, 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, PUBLIC_STATUS_BAR_VISIBILITY_MASK, 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, sPreserveMarginParamsInLayoutParamConversion, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SEARCH, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_TRANSIENT, STATUS_BAR_TRANSLUCENT, STATUS_BAR_TRANSPARENT, STATUS_BAR_UNHIDE, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, 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, SYSTEM_UI_TRANSPARENT, 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
Constructor and Description |
---|
ProgressBar(Context context)
Create a new progress bar with range 0...100 and initial progress of 0.
|
ProgressBar(Context context,
AttributeSet attrs) |
ProgressBar(Context context,
AttributeSet attrs,
int defStyleAttr) |
ProgressBar(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes) |
Modifier and Type | Method and Description |
---|---|
void |
drawableHotspotChanged(float x,
float y)
This function is called whenever the view hotspot changes and needs to
be propagated to drawables or child views managed by the view.
|
protected void |
drawableStateChanged()
This function is called whenever the state of the view changes in such
a way that it impacts the state of drawables being shown.
|
protected void |
encodeProperties(ViewHierarchyEncoder stream) |
CharSequence |
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes.
|
Drawable |
getIndeterminateDrawable()
Get the drawable used to draw the progress bar in
indeterminate mode.
|
ColorStateList |
getIndeterminateTintList() |
PorterDuff.Mode |
getIndeterminateTintMode()
Returns the blending mode used to apply the tint to the indeterminate
drawable, if specified.
|
Interpolator |
getInterpolator()
Gets the acceleration curve type for the indeterminate animation.
|
int |
getMax()
Return the upper limit of this progress bar's range.
|
int |
getProgress()
Get the progress bar's current level of progress.
|
ColorStateList |
getProgressBackgroundTintList()
Returns the tint applied to the progress background, if specified.
|
PorterDuff.Mode |
getProgressBackgroundTintMode() |
Drawable |
getProgressDrawable()
Get the drawable used to draw the progress bar in
progress mode.
|
ColorStateList |
getProgressTintList()
Returns the tint applied to the progress drawable, if specified.
|
PorterDuff.Mode |
getProgressTintMode()
Returns the blending mode used to apply the tint to the progress
drawable, if specified.
|
int |
getSecondaryProgress()
Get the progress bar's current level of secondary progress.
|
ColorStateList |
getSecondaryProgressTintList()
Returns the tint applied to the secondary progress drawable, if
specified.
|
PorterDuff.Mode |
getSecondaryProgressTintMode()
Returns the blending mode used to apply the tint to the secondary
progress drawable, if specified.
|
void |
incrementProgressBy(int diff)
Increase the progress bar's progress by the specified amount.
|
void |
incrementSecondaryProgressBy(int diff)
Increase the progress bar's secondary progress by the specified amount.
|
void |
invalidateDrawable(Drawable dr)
Invalidates the specified Drawable.
|
boolean |
isIndeterminate()
Indicate whether this progress bar is in indeterminate mode.
|
void |
jumpDrawablesToCurrentState()
Call
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view. |
protected void |
onAttachedToWindow()
This is called when the view is attached to a window.
|
protected void |
onDetachedFromWindow()
This is called when the view is detached from a window.
|
protected void |
onDraw(Canvas canvas)
Implement this to do your drawing.
|
void |
onInitializeAccessibilityEventInternal(AccessibilityEvent event) |
void |
onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec)
Measure the view and its content to determine the measured width and the
measured height.
|
void |
onResolveDrawables(int layoutDirection)
Called when layout direction has been resolved.
|
void |
onRestoreInstanceState(Parcelable state)
Hook allowing a view to re-apply a representation of its internal state that had previously
been generated by
View.onSaveInstanceState() . |
Parcelable |
onSaveInstanceState()
Hook allowing a view to generate a representation of its internal state
that can later be used to create a new instance with that same state.
|
protected void |
onSizeChanged(int w,
int h,
int oldw,
int oldh)
This is called during layout when the size of this view has changed.
|
void |
onVisibilityAggregated(boolean isVisible)
Called when the user-visibility of this View is potentially affected by a change
to this view itself, an ancestor view or the window this view is attached to.
|
void |
postInvalidate()
Cause an invalidate to happen on a subsequent cycle through the event loop.
|
void |
setIndeterminate(boolean indeterminate)
Change the indeterminate mode for this progress bar.
|
void |
setIndeterminateDrawable(Drawable d)
Define the drawable used to draw the progress bar in indeterminate mode.
|
void |
setIndeterminateDrawableTiled(Drawable d)
Define the tileable drawable used to draw the progress bar in
indeterminate mode.
|
void |
setIndeterminateTintList(ColorStateList tint)
Applies a tint to the indeterminate drawable.
|
void |
setIndeterminateTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
setIndeterminateTintList(ColorStateList) to the indeterminate
drawable. |
void |
setInterpolator(Context context,
int resID)
Sets the acceleration curve for the indeterminate animation.
|
void |
setInterpolator(Interpolator interpolator)
Sets the acceleration curve for the indeterminate animation.
|
void |
setMax(int max)
Set the range of the progress bar to 0...
|
void |
setProgress(int progress)
Sets the current progress to the specified value.
|
void |
setProgress(int progress,
boolean animate)
Sets the current progress to the specified value, optionally animating
the visual position between the current and target values.
|
void |
setProgressBackgroundTintList(ColorStateList tint)
Applies a tint to the progress background, if one exists.
|
void |
setProgressBackgroundTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
setProgressBackgroundTintList(ColorStateList) } to the progress
background. |
void |
setProgressDrawable(Drawable d)
Define the drawable used to draw the progress bar in progress mode.
|
void |
setProgressDrawableTiled(Drawable d)
Define the tileable drawable used to draw the progress bar in
progress mode.
|
void |
setProgressTintList(ColorStateList tint)
Applies a tint to the progress indicator, if one exists, or to the
entire progress drawable otherwise.
|
void |
setProgressTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
setProgressTintList(ColorStateList) } to the progress
indicator. |
void |
setSecondaryProgress(int secondaryProgress)
Set the current secondary progress to the specified value.
|
void |
setSecondaryProgressTintList(ColorStateList tint)
Applies a tint to the secondary progress indicator, if one exists.
|
void |
setSecondaryProgressTintMode(PorterDuff.Mode tintMode)
Specifies the blending mode used to apply the tint specified by
setSecondaryProgressTintList(ColorStateList) } to the secondary
progress indicator. |
protected boolean |
verifyDrawable(Drawable who)
If your view subclass is displaying its own Drawable objects, it should
override this function and return true for any Drawable it is
displaying.
|
addChildrenForAccessibility, addFocusables, addFocusables, addFrameMetricsListener, addOnAttachStateChangeListener, addOnLayoutChangeListener, addTouchables, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelDragAndDrop, cancelLongPress, cancelPendingInputEvents, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, captureTransitioningViews, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, clearFocus, combineMeasuredStates, computeFitSystemWindows, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeOpaqueFlags, computeScroll, computeSystemWindowInsets, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createAccessibilityNodeInfoInternal, createContextMenu, createSnapshot, damageInParent, debug, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchActivityResult, dispatchApplyWindowInsets, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchDrawableHotspotChanged, dispatchFinishTemporaryDetach, dispatchGenericFocusedEvent, dispatchGenericMotionEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchNestedFling, dispatchNestedPreFling, dispatchNestedPrePerformAccessibilityAction, dispatchNestedPreScroll, dispatchNestedScroll, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, dispatchPopulateAccessibilityEventInternal, dispatchProvideStructure, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, draw, encode, findFocus, findNamedViews, findViewByAccessibilityIdTraversal, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewByPredicateTraversal, findViewsWithText, findViewTraversal, findViewWithTag, findViewWithTagTraversal, fitsSystemWindows, fitSystemWindows, focusSearch, forceHasOverlappingRendering, forceLayout, gatherTransparentRegion, generateViewId, getAccessibilityDelegate, getAccessibilityLiveRegion, getAccessibilityNodeProvider, getAccessibilitySelectionEnd, getAccessibilitySelectionStart, getAccessibilityTraversalAfter, getAccessibilityTraversalBefore, getAccessibilityViewId, getAccessibilityWindowId, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBackgroundTintList, getBackgroundTintMode, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getBoundsOnScreen, getBoundsOnScreen, getCameraDistance, getClipBounds, getClipBounds, getClipToOutline, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplay, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getElevation, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getForeground, getForegroundGravity, getForegroundTintList, getForegroundTintMode, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHasOverlappingRendering, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getHotspotBounds, getId, getImportantForAccessibility, getInverseMatrix, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLabelFor, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInSurface, getLocationInWindow, getLocationOnScreen, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOutlineProvider, getOutsets, getOverlay, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getPointerIcon, getRawLayoutDirection, getRawTextAlignment, getRawTextDirection, getResources, getRevealOnFocusHint, 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, getTransitionAlpha, getTransitionName, getTranslationX, getTranslationY, getTranslationZ, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowDisplayFrame, getWindowId, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, getZ, handleScrollBarDragging, hasFocus, hasFocusable, hasHoveredChild, hasNestedScrollingParent, hasOnClickListeners, hasOpaqueScrollbars, hasOverlappingRendering, hasShadow, hasTransientState, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeFadingEdgeInternal, initializeScrollbars, initializeScrollbarsInternal, internalSetPadding, invalidate, invalidate, invalidate, invalidateOutline, invalidateParentCaches, invalidateParentIfNeeded, invalidateParentIfNeededAndWasQuickRejected, isAccessibilityFocused, isAccessibilitySelectionExtendable, isActionableForAccessibility, isActivated, isAssistBlocked, isAttachedToWindow, isClickable, isContextClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isForegroundInsidePadding, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInLayout, isInScrollingContainer, isInTouchMode, isLaidOut, isLayoutDirectionInherited, isLayoutDirectionResolved, isLayoutModeOptical, isLayoutRequested, isLayoutRtl, isLongClickable, isNestedScrollingEnabled, isOpaque, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isTemporarilyDetached, isTextAlignmentInherited, isTextAlignmentResolved, isTextDirectionInherited, isTextDirectionResolved, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, layout, makeOptionalFitsSystemWindows, measure, mergeDrawableStates, notifySubtreeAccessibilityStateChangedIfNeeded, notifyViewAccessibilityStateChangedIfNeeded, offsetLeftAndRight, offsetTopAndBottom, onActivityResult, onAnimationEnd, onAnimationStart, onApplyWindowInsets, onCancelPendingInputEvents, onCheckIsTextEditor, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onCreateDrawableState, onCreateInputConnection, onDetachedFromWindowInternal, onDisplayHint, onDragEvent, onDrawForeground, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusChanged, onFocusLost, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyDown, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onKeyUp, onLayout, onOverScrolled, onPopulateAccessibilityEvent, onPopulateAccessibilityEventInternal, onProvideStructure, onProvideVirtualStructure, onRenderNodeDetached, onResolvePointerIcon, onRtlPropertiesChanged, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onTouchEvent, onTrackballEvent, onVisibilityChanged, onWindowFocusChanged, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performAccessibilityActionInternal, performButtonActionOnTouchDown, performClick, performContextClick, performContextClick, performHapticFeedback, performHapticFeedback, performLongClick, performLongClick, playSoundEffect, pointInView, post, postDelayed, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeFrameMetricsListener, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestApplyInsets, requestFitSystemWindows, requestFocus, requestFocus, requestFocus, requestFocusFromTouch, requestKeyboardShortcuts, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, requestUnbufferedDispatch, resetPaddingToInitialValues, resetResolvedDrawables, resetResolvedLayoutDirection, resetResolvedPadding, resetResolvedTextAlignment, resetResolvedTextDirection, resetRtlProperties, resolveDrawables, resolveLayoutDirection, resolveLayoutParams, resolvePadding, resolveRtlPropertiesIfNeeded, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventInternal, sendAccessibilityEventUnchecked, sendAccessibilityEventUncheckedInternal, setAccessibilityDelegate, setAccessibilityLiveRegion, setAccessibilitySelection, setAccessibilityTraversalAfter, setAccessibilityTraversalBefore, setActivated, setAlpha, setAnimation, setAnimationMatrix, setAssistBlocked, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBackgroundTintList, setBackgroundTintMode, setBottom, setCameraDistance, setClickable, setClipBounds, setClipToOutline, setContentDescription, setContextClickable, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setElevation, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setForeground, setForegroundGravity, setForegroundTintList, setForegroundTintMode, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLabelFor, setLayerPaint, setLayerType, setLayoutDirection, setLayoutParams, setLeft, setLeftTopRightBottom, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNestedScrollingEnabled, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnApplyWindowInsetsListener, setOnClickListener, setOnContextClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnScrollChangeListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOpticalInsets, setOutlineProvider, setOverScrollMode, setPadding, setPaddingRelative, setPivotX, setPivotY, setPointerIcon, setPressed, setRevealClip, setRevealOnFocusHint, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollIndicators, setScrollIndicators, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setStateListAnimator, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTransitionAlpha, setTransitionName, setTransitionVisibility, setTranslationX, setTranslationY, setTranslationZ, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, setZ, showContextMenu, showContextMenu, startActionMode, startActionMode, startActivityForResult, startAnimation, startDrag, startDragAndDrop, startMovingTask, startNestedScroll, stopNestedScroll, toGlobalMotionEvent, toLocalMotionEvent, toString, transformFromViewToWindowSpace, transformMatrixToGlobal, transformMatrixToLocal, unscheduleDrawable, unscheduleDrawable, updateDisplayListIfDirty, updateDragShadow, willNotCacheDrawing, willNotDraw
public ProgressBar(Context context)
context
- the application environmentpublic ProgressBar(Context context, AttributeSet attrs)
public ProgressBar(Context context, AttributeSet attrs, int defStyleAttr)
public ProgressBar(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
public boolean isIndeterminate()
Indicate whether this progress bar is in indeterminate mode.
public void setIndeterminate(boolean indeterminate)
Change the indeterminate mode for this progress bar. In indeterminate mode, the progress is ignored and the progress bar shows an infinite animation instead.
If this progress bar's style only supports indeterminate mode (such as the circular progress bars), then this will be ignored.indeterminate
- true to enable the indeterminate modepublic Drawable getIndeterminateDrawable()
Get the drawable used to draw the progress bar in indeterminate mode.
Drawable
instancesetIndeterminateDrawable(android.graphics.drawable.Drawable)
,
setIndeterminate(boolean)
public void setIndeterminateDrawable(Drawable d)
d
- the new drawablegetIndeterminateDrawable()
,
setIndeterminate(boolean)
public void setIndeterminateTintList(ColorStateList tint)
PorterDuff.Mode#SRC_IN
by default.
Subsequent calls to setIndeterminateDrawable(Drawable)
will
automatically mutate the drawable and apply the specified tint and
tint mode using
Drawable.setTintList(ColorStateList)
.
tint
- the tint to apply, may be null
to clear tintgetIndeterminateTintList()
,
Drawable.setTintList(ColorStateList)
public ColorStateList getIndeterminateTintList()
setIndeterminateTintList(ColorStateList)
public void setIndeterminateTintMode(PorterDuff.Mode tintMode)
setIndeterminateTintList(ColorStateList)
to the indeterminate
drawable. The default mode is PorterDuff.Mode#SRC_IN
.tintMode
- the blending mode used to apply the tint, may be
null
to clear tintsetIndeterminateTintList(ColorStateList)
,
Drawable.setTintMode(PorterDuff.Mode)
public PorterDuff.Mode getIndeterminateTintMode()
setIndeterminateTintMode(PorterDuff.Mode)
public void setIndeterminateDrawableTiled(Drawable d)
If the drawable is a BitmapDrawable or contains BitmapDrawables, a tiled copy will be generated for display as a progress bar.
d
- the new drawablegetIndeterminateDrawable()
,
setIndeterminate(boolean)
public Drawable getProgressDrawable()
Get the drawable used to draw the progress bar in progress mode.
Drawable
instancesetProgressDrawable(android.graphics.drawable.Drawable)
,
setIndeterminate(boolean)
public void setProgressDrawable(Drawable d)
d
- the new drawablegetProgressDrawable()
,
setIndeterminate(boolean)
public void setProgressTintList(ColorStateList tint)
PorterDuff.Mode#SRC_IN
by default.
The progress indicator should be specified as a layer with
id android.R.id#progress
in a LayerDrawable
used as the progress drawable.
Subsequent calls to setProgressDrawable(Drawable)
will
automatically mutate the drawable and apply the specified tint and
tint mode using
Drawable.setTintList(ColorStateList)
.
tint
- the tint to apply, may be null
to clear tintgetProgressTintList()
,
Drawable.setTintList(ColorStateList)
public ColorStateList getProgressTintList()
setProgressTintList(ColorStateList)
public void setProgressTintMode(PorterDuff.Mode tintMode)
setProgressTintList(ColorStateList)
} to the progress
indicator. The default mode is PorterDuff.Mode#SRC_IN
.tintMode
- the blending mode used to apply the tint, may be
null
to clear tintgetProgressTintMode()
,
Drawable.setTintMode(PorterDuff.Mode)
public PorterDuff.Mode getProgressTintMode()
setProgressTintMode(PorterDuff.Mode)
public void setProgressBackgroundTintList(ColorStateList tint)
PorterDuff.Mode#SRC_ATOP
by default.
The progress background must be specified as a layer with
id android.R.id#background
in a LayerDrawable
used as the progress drawable.
Subsequent calls to setProgressDrawable(Drawable)
where the
drawable contains a progress background will automatically mutate the
drawable and apply the specified tint and tint mode using
Drawable.setTintList(ColorStateList)
.
tint
- the tint to apply, may be null
to clear tintgetProgressBackgroundTintList()
,
Drawable.setTintList(ColorStateList)
public ColorStateList getProgressBackgroundTintList()
setProgressBackgroundTintList(ColorStateList)
public void setProgressBackgroundTintMode(PorterDuff.Mode tintMode)
setProgressBackgroundTintList(ColorStateList)
} to the progress
background. The default mode is PorterDuff.Mode#SRC_IN
.tintMode
- the blending mode used to apply the tint, may be
null
to clear tintsetProgressBackgroundTintList(ColorStateList)
,
Drawable.setTintMode(PorterDuff.Mode)
public PorterDuff.Mode getProgressBackgroundTintMode()
setProgressBackgroundTintMode(PorterDuff.Mode)
public void setSecondaryProgressTintList(ColorStateList tint)
PorterDuff.Mode#SRC_ATOP
by default.
The secondary progress indicator must be specified as a layer with
id android.R.id#secondaryProgress
in a LayerDrawable
used as the progress drawable.
Subsequent calls to setProgressDrawable(Drawable)
where the
drawable contains a secondary progress indicator will automatically
mutate the drawable and apply the specified tint and tint mode using
Drawable.setTintList(ColorStateList)
.
tint
- the tint to apply, may be null
to clear tintgetSecondaryProgressTintList()
,
Drawable.setTintList(ColorStateList)
public ColorStateList getSecondaryProgressTintList()
setSecondaryProgressTintList(ColorStateList)
public void setSecondaryProgressTintMode(PorterDuff.Mode tintMode)
setSecondaryProgressTintList(ColorStateList)
} to the secondary
progress indicator. The default mode is
PorterDuff.Mode#SRC_ATOP
.tintMode
- the blending mode used to apply the tint, may be
null
to clear tintsetSecondaryProgressTintList(ColorStateList)
,
Drawable.setTintMode(PorterDuff.Mode)
public PorterDuff.Mode getSecondaryProgressTintMode()
setSecondaryProgressTintMode(PorterDuff.Mode)
public void setProgressDrawableTiled(Drawable d)
If the drawable is a BitmapDrawable or contains BitmapDrawables, a tiled copy will be generated for display as a progress bar.
d
- the new drawablegetProgressDrawable()
,
setIndeterminate(boolean)
protected boolean verifyDrawable(Drawable who)
View
Be sure to call through to the super class when overriding this function.
verifyDrawable
in class View
who
- The Drawable to verify. Return true if it is one you are
displaying, else return the result of calling through to the
super class.View.unscheduleDrawable(android.graphics.drawable.Drawable)
,
View.drawableStateChanged()
public void jumpDrawablesToCurrentState()
View
Drawable.jumpToCurrentState()
on all Drawable objects associated with this view.
Also calls StateListAnimator.jumpToCurrentState()
if there is a StateListAnimator
attached to this view.
jumpDrawablesToCurrentState
in class View
public void onResolveDrawables(int layoutDirection)
View
onResolveDrawables
in class View
layoutDirection
- The resolved layout direction.View.LAYOUT_DIRECTION_LTR
,
View.LAYOUT_DIRECTION_RTL
public void postInvalidate()
View
Cause an invalidate to happen on a subsequent cycle through the event loop. Use this to invalidate the View from a non-UI thread.
This method can be invoked from outside of the UI thread only when this View is attached to a window.
postInvalidate
in class View
View.invalidate()
,
View.postInvalidateDelayed(long)
public void setProgress(int progress)
This method will immediately update the visual position of the progress
indicator. To animate the visual position to the target value, use
setProgress(int, boolean)
}.
progress
- the new progress, between 0 and getMax()
setIndeterminate(boolean)
,
isIndeterminate()
,
getProgress()
,
incrementProgressBy(int)
public void setProgress(int progress, boolean animate)
Animation does not affect the result of getProgress()
, which
will return the target value immediately after this method is called.
progress
- the new progress value, between 0 and getMax()
animate
- true
to animate between the current and target
values or false
to not animatepublic void setSecondaryProgress(int secondaryProgress)
Set the current secondary progress to the specified value. Does not do anything if the progress bar is in indeterminate mode.
secondaryProgress
- the new secondary progress, between 0 and getMax()
setIndeterminate(boolean)
,
isIndeterminate()
,
getSecondaryProgress()
,
incrementSecondaryProgressBy(int)
public int getProgress()
Get the progress bar's current level of progress. Return 0 when the progress bar is in indeterminate mode.
getMax()
setIndeterminate(boolean)
,
isIndeterminate()
,
setProgress(int)
,
setMax(int)
,
getMax()
public int getSecondaryProgress()
Get the progress bar's current level of secondary progress. Return 0 when the progress bar is in indeterminate mode.
getMax()
setIndeterminate(boolean)
,
isIndeterminate()
,
setSecondaryProgress(int)
,
setMax(int)
,
getMax()
public int getMax()
Return the upper limit of this progress bar's range.
setMax(int)
,
getProgress()
,
getSecondaryProgress()
public void setMax(int max)
Set the range of the progress bar to 0...max.
max
- the upper range of this progress bargetMax()
,
setProgress(int)
,
setSecondaryProgress(int)
public final void incrementProgressBy(int diff)
Increase the progress bar's progress by the specified amount.
diff
- the amount by which the progress must be increasedsetProgress(int)
public final void incrementSecondaryProgressBy(int diff)
Increase the progress bar's secondary progress by the specified amount.
diff
- the amount by which the secondary progress must be increasedsetSecondaryProgress(int)
public void setInterpolator(Context context, @InterpolatorRes int resID)
context
- The application environmentresID
- The resource identifier of the interpolator to loadpublic void setInterpolator(Interpolator interpolator)
interpolator
- The interpolator which defines the acceleration curvepublic Interpolator getInterpolator()
Interpolator
associated to this animationpublic void onVisibilityAggregated(boolean isVisible)
View
onVisibilityAggregated
in class View
isVisible
- true if this view and all of its ancestors are View.VISIBLE
and this view's window is also visiblepublic void invalidateDrawable(Drawable dr)
View
invalidateDrawable
in interface Drawable.Callback
invalidateDrawable
in class View
dr
- the drawable to invalidateprotected void onSizeChanged(int w, int h, int oldw, int oldh)
View
onSizeChanged
in class View
w
- Current width of this view.h
- Current height of this view.oldw
- Old width of this view.oldh
- Old height of this view.protected void onDraw(Canvas canvas)
View
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
View
Measure the view and its content to determine the measured width and the
measured height. This method is invoked by View.measure(int, int)
and
should be overridden by subclasses to provide accurate and efficient
measurement of their contents.
CONTRACT: When overriding this method, you
must call View.setMeasuredDimension(int, int)
to store the
measured width and height of this view. Failure to do so will trigger an
IllegalStateException
, thrown by
View.measure(int, int)
. Calling the superclass'
View.onMeasure(int, int)
is a valid use.
The base class implementation of measure defaults to the background size,
unless a larger size is allowed by the MeasureSpec. Subclasses should
override View.onMeasure(int, int)
to provide better measurements of
their content.
If this method is overridden, it is the subclass's responsibility to make
sure the measured height and width are at least the view's minimum height
and width (View.getSuggestedMinimumHeight()
and
View.getSuggestedMinimumWidth()
).
onMeasure
in class View
widthMeasureSpec
- horizontal space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.heightMeasureSpec
- vertical space requirements as imposed by the parent.
The requirements are encoded with
View.MeasureSpec
.View.getMeasuredWidth()
,
View.getMeasuredHeight()
,
View.setMeasuredDimension(int, int)
,
View.getSuggestedMinimumHeight()
,
View.getSuggestedMinimumWidth()
,
View.MeasureSpec.getMode(int)
,
View.MeasureSpec.getSize(int)
protected void drawableStateChanged()
View
If the View has a StateListAnimator, it will also be called to run necessary state change animations.
Be sure to call through to the superclass when overriding this function.
drawableStateChanged
in class View
Drawable.setState(int[])
public void drawableHotspotChanged(float x, float y)
View
Dispatching to child views is handled by
View.dispatchDrawableHotspotChanged(float, float)
.
Be sure to call through to the superclass when overriding this function.
drawableHotspotChanged
in class View
x
- hotspot x coordinatey
- hotspot y coordinatepublic Parcelable onSaveInstanceState()
View
Some examples of things you may store here: the current cursor position in a text view (but usually not the text itself since that is stored in a content provider or other persistent storage), the currently selected item in a list view.
onSaveInstanceState
in class View
View.onRestoreInstanceState(android.os.Parcelable)
,
View.saveHierarchyState(android.util.SparseArray)
,
View.dispatchSaveInstanceState(android.util.SparseArray)
,
View.setSaveEnabled(boolean)
public void onRestoreInstanceState(Parcelable state)
View
View.onSaveInstanceState()
. This function will never be called with a
null state.onRestoreInstanceState
in class View
state
- The frozen state that had previously been returned by
View.onSaveInstanceState()
.View.onSaveInstanceState()
,
View.restoreHierarchyState(android.util.SparseArray)
,
View.dispatchRestoreInstanceState(android.util.SparseArray)
protected void onAttachedToWindow()
View
View.onDraw(android.graphics.Canvas)
,
however it may be called any time before the first onDraw -- including
before or after View.onMeasure(int, int)
.onAttachedToWindow
in class View
View.onDetachedFromWindow()
protected void onDetachedFromWindow()
View
onDetachedFromWindow
in class View
View.onAttachedToWindow()
public CharSequence getAccessibilityClassName()
View
AccessibilityNodeInfo.setClassName
.getAccessibilityClassName
in class View
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event)
onInitializeAccessibilityEventInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info)
onInitializeAccessibilityNodeInfoInternal
in class View
Note: Called from the default {@link AccessibilityDelegate}.
protected void encodeProperties(ViewHierarchyEncoder stream)
View
encodeProperties
in class View