Added in API level 1

ProgressBar


open class ProgressBar : View
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.ProgressBar

A user interface element that indicates the progress of an operation. Progress bar supports two modes to represent progress: determinate, and indeterminate. For a visual overview of the difference between determinate and indeterminate progress modes, see Progress & activity. Display progress bars to a user in a non-interruptive way. Show the progress bar in your app's user interface or in a notification instead of within a dialog.

Indeterminate Progress

Use indeterminate mode for the progress bar when you do not know how long an operation will take. Indeterminate mode is the default for progress bar and shows a cyclic animation without a specific amount of progress indicated. The following example shows an indeterminate progress bar:

<ProgressBar
       android:id="@+id/indeterminateBar"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       />
  

Determinate Progress

Use determinate mode for the progress bar when you want to show that a specific quantity of progress has occurred. For example, the percent remaining of a file being retrieved, the amount records in a batch written to database, or the percent remaining of an audio file that is playing.

To indicate determinate progress, you set the style of the progress bar to android.R.style#Widget_ProgressBar_Horizontal and set the amount of progress. The following example shows a determinate progress bar that is 25% complete:

<ProgressBar
       android:id="@+id/determinateBar"
       style="@android:style/Widget.ProgressBar.Horizontal"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:progress="25"/>
  
You can update the percentage of progress displayed by using the setProgress(int) method, or by calling incrementProgressBy(int) to increase the current progress completed by a specified amount. By default, the progress bar is full when the progress value reaches 100. You can adjust this default by setting the android:max attribute.

Other progress bar styles provided by the system include:

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).

Accessibility

Consider using AccessibilityNodeInfo.setMinDurationBetweenContentChanges(Duration) to convey to accessibility services that changes can be throttled. This may reduce the frequency of potentially disruptive notifications.

XML attributes

See ProgressBar Attributes, View Attributes

Summary

XML attributes
android:animationResolution Timeout between frames of animation in milliseconds.
android:indeterminate Allows to enable the indeterminate mode.
android:indeterminateBehavior Defines how the indeterminate mode should behave when the progress reaches max.
android:indeterminateDrawable Drawable used for the indeterminate mode.
android:indeterminateDuration Duration of the indeterminate animation.
android:indeterminateOnly Restricts to ONLY indeterminate mode (state-keeping progress mode will not work).
android:interpolator Sets the acceleration curve for the indeterminate animation.
android:max Defines the maximum value.
android:maxHeight An optional argument to supply a maximum height for this view.
android:maxWidth An optional argument to supply a maximum width for this view.
android:min Defines the minimum value.
android:minHeight
android:minWidth
android:mirrorForRtl Defines if the associated drawables need to be mirrored when in RTL mode.
android:progress Defines the default progress value, between 0 and max.
android:progressDrawable Drawable used for the progress mode.
android:secondaryProgress Defines the secondary progress value, between 0 and max.
Inherited XML attributes
Inherited constants
Public constructors
ProgressBar(context: Context!)

Create a new progress bar with range 0.

ProgressBar(context: Context!, attrs: AttributeSet!)

ProgressBar(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

ProgressBar(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit

open CharSequence!

open Drawable?

Returns the drawable currently used to draw the progress bar.

open Drawable!

Get the drawable used to draw the progress bar in indeterminate mode.

open BlendMode?

Returns the blending mode used to apply the tint to the indeterminate drawable, if specified.

open ColorStateList?

open PorterDuff.Mode?

Returns the blending mode used to apply the tint to the indeterminate drawable, if specified.

open Interpolator!

Gets the acceleration curve type for the indeterminate animation.

open Int

Return the upper limit of this progress bar's range.

open Int


The units of this value are pixels.

open Int


The units of this value are pixels.

open Int

Return the lower limit of this progress bar's range.

open Int


The units of this value are pixels.

open Int


The units of this value are pixels.

open Int

Get the progress bar's current level of progress.

open BlendMode?

open ColorStateList?

Returns the tint applied to the progress background, if specified.

open PorterDuff.Mode?

open Drawable!

Get the drawable used to draw the progress bar in progress mode.

open BlendMode?

Returns the blending mode used to apply the tint to the progress drawable, if specified.

open ColorStateList?

Returns the tint applied to the progress drawable, if specified.

open PorterDuff.Mode?

Returns the blending mode used to apply the tint to the progress drawable, if specified.

open Int

Get the progress bar's current level of secondary progress.

open BlendMode?

Returns the blending mode used to apply the tint to the secondary progress drawable, if specified.

open ColorStateList?

Returns the tint applied to the secondary progress drawable, if specified.

open PorterDuff.Mode?

Returns the blending mode used to apply the tint to the secondary progress drawable, if specified.

Unit

Increase the progress bar's progress by the specified amount.

Unit

Increase the progress bar's secondary progress by the specified amount.

open Unit

Invalidates the specified Drawable.

open Boolean

Returns whether the ProgressBar is animating or not.

open Boolean

Indicate whether this progress bar is in indeterminate mode.

open Unit

open Unit

open Parcelable?

open Unit

open Unit

open Unit
setIndeterminate(indeterminate: Boolean)

Change the indeterminate mode for this progress bar.

open Unit

Define the drawable used to draw the progress bar in indeterminate mode.

open Unit

Define the tileable drawable used to draw the progress bar in indeterminate mode.

open Unit

Specifies the blending mode used to apply the tint specified by setIndeterminateTintList(android.content.res.ColorStateList) to the indeterminate drawable.

open Unit

Applies a tint to the indeterminate drawable.

open Unit

Specifies the blending mode used to apply the tint specified by setIndeterminateTintList(android.content.res.ColorStateList) to the indeterminate drawable.

open Unit
setInterpolator(context: Context!, resID: Int)

Sets the acceleration curve for the indeterminate animation.

open Unit
setInterpolator(interpolator: Interpolator!)

Sets the acceleration curve for the indeterminate animation.

open Unit
setMax(max: Int)

Set the upper range of the progress bar max.

open Unit
setMaxHeight(maxHeight: Int)

Sets the maximum height the progress bar can have.

open Unit
setMaxWidth(maxWidth: Int)

Sets the maximum width the progress bar can have.

open Unit
setMin(min: Int)

Set the lower range of the progress bar to min.

open Unit
setMinHeight(minHeight: Int)

Sets the minimum height the progress bar can have.

open Unit
setMinWidth(minWidth: Int)

Sets the minimum width the progress bar can have.

open Unit
setProgress(progress: Int)

Sets the current progress to the specified value.

open Unit
setProgress(progress: Int, animate: Boolean)

Sets the current progress to the specified value, optionally animating the visual position between the current and target values.

open Unit

Specifies the blending mode used to apply the tint specified by setProgressBackgroundTintList(android.content.res.ColorStateList)} to the progress background.

open Unit

Applies a tint to the progress background, if one exists.

open Unit

Specifies the blending mode used to apply the tint specified by setProgressBackgroundTintList(android.content.res.ColorStateList)} to the progress background.

open Unit

Define the drawable used to draw the progress bar in progress mode.

open Unit

Define the tileable drawable used to draw the progress bar in progress mode.

open Unit

Specifies the blending mode used to apply the tint specified by setProgressTintList(android.content.res.ColorStateList)} to the progress indicator.

open Unit

Applies a tint to the progress indicator, if one exists, or to the entire progress drawable otherwise.

open Unit

Specifies the blending mode used to apply the tint specified by setProgressTintList(android.content.res.ColorStateList)} to the progress indicator.

open Unit
setSecondaryProgress(secondaryProgress: Int)

Set the current secondary progress to the specified value.

open Unit

Specifies the blending mode used to apply the tint specified by setSecondaryProgressTintList(android.content.res.ColorStateList)} to the secondary progress indicator.

open Unit

Applies a tint to the secondary progress indicator, if one exists.

open Unit

Specifies the blending mode used to apply the tint specified by setSecondaryProgressTintList(android.content.res.ColorStateList)} to the secondary progress indicator.

open Unit
setStateDescription(stateDescription: CharSequence?)

This function is called when an instance or subclass sets the state description.

Protected methods
open Unit

open Unit

open Unit

open Unit
onDraw(canvas: Canvas)

open Unit
onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int)

open Unit
onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int)

open Boolean

If your view subclass is displaying its own Drawable objects, it should override this function and return true for any Drawable it is displaying.

Inherited functions