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
Inherited properties

XML attributes

android:animationResolution

android:animationResolution
Timeout between frames of animation in milliseconds. {@deprecated Not used by the framework}.

May be an integer value, such as "100".

android:indeterminate

android:indeterminate
Allows to enable the indeterminate mode. In this mode the progress bar plays an infinite looping animation.

May be a boolean value, such as "true" or "false".

android:indeterminateBehavior

android:indeterminateBehavior
Defines how the indeterminate mode should behave when the progress reaches max. Only affects the indeterminate animation if the indeterminate Drawable does not implement android.graphics.drawable.Animatable.

Must be one of the following constant values.

Constant Value Description
cycle 2 Progress keeps the current value and goes back to 0.
repeat 1 Progress starts over from 0.

android:indeterminateDrawable

android:indeterminateDrawable
Drawable used for the indeterminate mode. One that implements Animatable offers more control over the animation.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:indeterminateDuration

android:indeterminateDuration
Duration of the indeterminate animation. Only affects the indeterminate animation if the indeterminate Drawable does not implement android.graphics.drawable.Animatable.

May be an integer value, such as "100".

android:indeterminateOnly

android:indeterminateOnly
Restricts to ONLY indeterminate mode (state-keeping progress mode will not work).

May be a boolean value, such as "true" or "false".

android:interpolator

android:interpolator
Sets the acceleration curve for the indeterminate animation. Defaults to a linear interpolation. Only affects the indeterminate animation if the indeterminate Drawable does not implement android.graphics.drawable.Animatable.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:max

android:max
Defines the maximum value.

May be an integer value, such as "100".

android:maxHeight

android:maxHeight
An optional argument to supply a maximum height for this view. See {see android.widget.ImageView#setMaxHeight} for details.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:maxWidth

android:maxWidth
An optional argument to supply a maximum width for this view. See {see android.widget.ImageView#setMaxWidth} for details.

May be a dimension value, which is a floating point number appended with a unit such as "14.5sp". Available units are: px (pixels), dp (density-independent pixels), sp (scaled pixels based on preferred font size), in (inches), and mm (millimeters).

android:min

android:min
Defines the minimum value.

May be an integer value, such as "100".

android:minHeight

android:minHeight

android:minWidth

android:minWidth

android:mirrorForRtl

android:mirrorForRtl
Defines if the associated drawables need to be mirrored when in RTL mode. Default is false.

May be a boolean value, such as "true" or "false".

android:progress

android:progress
Defines the default progress value, between 0 and max.

May be an integer value, such as "100".

android:progressDrawable

android:progressDrawable
Drawable used for the progress mode.

May be a reference to another resource, in the form "@[+][package:]type/name" or a theme attribute in the form "?[package:]type/name".

android:secondaryProgress

android:secondaryProgress
Defines the secondary progress value, between 0 and max. This progress is drawn between the primary progress and the background. It can be ideal for media scenarios such as showing the buffering progress while the default progress shows the play progress.

May be an integer value, such as "100".

Public constructors

ProgressBar

Added in API level 1
ProgressBar(context: Context!)

Create a new progress bar with range 0...100 and initial progress of 0.

Parameters
context Context!: the application environment

ProgressBar

Added in API level 1
ProgressBar(
    context: Context!,
    attrs: AttributeSet!)

ProgressBar

Added in API level 1
ProgressBar(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

ProgressBar

Added in API level 21
ProgressBar(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

drawableHotspotChanged

Added in API level 21
open fun drawableHotspotChanged(
    x: Float,
    y: Float
): Unit
Parameters
x Float: hotspot x coordinate
y Float: hotspot y coordinate

getAccessibilityClassName

Added in API level 23
open fun getAccessibilityClassName(): CharSequence!

getCurrentDrawable

Added in API level 29
open fun getCurrentDrawable(): Drawable?

Returns the drawable currently used to draw the progress bar. This will be either getProgressDrawable() or getIndeterminateDrawable() depending on whether the progress bar is in determinate or indeterminate mode.

Return
Drawable? the drawable currently used to draw the progress bar This value may be null.

getIndeterminateDrawable

Added in API level 1
open fun getIndeterminateDrawable(): Drawable!

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

Return
Drawable! a android.graphics.drawable.Drawable instance

getIndeterminateTintBlendMode

Added in API level 29
open fun getIndeterminateTintBlendMode(): BlendMode?

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

Return
BlendMode? the blending mode used to apply the tint to the indeterminate drawable This value may be null.

getIndeterminateTintList

Added in API level 21
open fun getIndeterminateTintList(): ColorStateList?
Return
ColorStateList? the tint applied to the indeterminate drawable This value may be null.

getIndeterminateTintMode

Added in API level 21
open fun getIndeterminateTintMode(): PorterDuff.Mode?

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

Return
PorterDuff.Mode? the blending mode used to apply the tint to the indeterminate drawable This value may be null.

getInterpolator

Added in API level 1
open fun getInterpolator(): Interpolator!

Gets the acceleration curve type for the indeterminate animation.

Return
Interpolator! the Interpolator associated to this animation

getMax

Added in API level 1
open fun getMax(): Int

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

Return
Int a positive integer

getMaxHeight

Added in API level 29
open fun getMaxHeight(): Int


The units of this value are pixels.

Return
Int the maximum height the progress bar can have, in pixels The units of this value are pixels. {}

getMaxWidth

Added in API level 29
open fun getMaxWidth(): Int


The units of this value are pixels.

Return
Int the maximum width the progress bar can have, in pixels The units of this value are pixels. {}

getMin

Added in API level 26
open fun getMin(): Int

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

Return
Int a positive integer

getMinHeight

Added in API level 29
open fun getMinHeight(): Int


The units of this value are pixels.

Return
Int the minimum height the progress bar can have, in pixels The units of this value are pixels. {}

getMinWidth

Added in API level 29
open fun getMinWidth(): Int


The units of this value are pixels.

Return
Int the minimum width the progress bar can have, in pixels The units of this value are pixels. {}

getProgress

Added in API level 1
open fun getProgress(): Int

Get the progress bar's current level of progress. Return 0 when the progress bar is in indeterminate mode.

Return
Int the current progress, between getMin() and getMax()

getProgressBackgroundTintBlendMode

Added in API level 29
open fun getProgressBackgroundTintBlendMode(): BlendMode?
Return
BlendMode? the blending mode used to apply the tint to the progress background This value may be null.

getProgressBackgroundTintList

Added in API level 21
open fun getProgressBackgroundTintList(): ColorStateList?

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

Return
ColorStateList? the tint applied to the progress background This value may be null.

getProgressBackgroundTintMode

Added in API level 21
open fun getProgressBackgroundTintMode(): PorterDuff.Mode?
Return
PorterDuff.Mode? the blending mode used to apply the tint to the progress background This value may be null.

getProgressDrawable

Added in API level 1
open fun getProgressDrawable(): Drawable!

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

Return
Drawable! a android.graphics.drawable.Drawable instance

getProgressTintBlendMode

Added in API level 29
open fun getProgressTintBlendMode(): BlendMode?

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

Return
BlendMode? the blending mode used to apply the tint to the progress drawable This value may be null.

getProgressTintList

Added in API level 21
open fun getProgressTintList(): ColorStateList?

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

Return
ColorStateList? the tint applied to the progress drawable This value may be null.

getProgressTintMode

Added in API level 21
open fun getProgressTintMode(): PorterDuff.Mode?

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

Return
PorterDuff.Mode? the blending mode used to apply the tint to the progress drawable This value may be null.

getSecondaryProgress

Added in API level 1
open fun getSecondaryProgress(): Int

Get the progress bar's current level of secondary progress. Return 0 when the progress bar is in indeterminate mode.

Return
Int the current secondary progress, between getMin() and getMax()

getSecondaryProgressTintBlendMode

Added in API level 29
open fun getSecondaryProgressTintBlendMode(): BlendMode?

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

Return
BlendMode? the blending mode used to apply the tint to the secondary progress drawable This value may be null.

getSecondaryProgressTintList

Added in API level 21
open fun getSecondaryProgressTintList(): ColorStateList?

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

Return
ColorStateList? the tint applied to the secondary progress drawable This value may be null.

getSecondaryProgressTintMode

Added in API level 21
open fun getSecondaryProgressTintMode(): PorterDuff.Mode?

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

Return
PorterDuff.Mode? the blending mode used to apply the tint to the secondary progress drawable This value may be null.

incrementProgressBy

Added in API level 1
fun incrementProgressBy(diff: Int): Unit

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

Parameters
diff Int: the amount by which the progress must be increased

incrementSecondaryProgressBy

Added in API level 1
fun incrementSecondaryProgressBy(diff: Int): Unit

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

Parameters
diff Int: the amount by which the secondary progress must be increased

invalidateDrawable

Added in API level 1
open fun invalidateDrawable(dr: Drawable): Unit

Invalidates the specified Drawable.

Parameters
who The drawable that is requesting the update. This value cannot be null.
drawable the drawable to invalidate This value cannot be null.
dr Drawable: This value cannot be null.

isAnimating

Added in API level 26
open fun isAnimating(): Boolean

Returns whether the ProgressBar is animating or not. This is essentially the same as whether the ProgressBar is indeterminate and visible, as indeterminate ProgressBars are always animating, and non-indeterminate ProgressBars are not animating.

Return
Boolean true if the ProgressBar is animating, false otherwise.

isIndeterminate

Added in API level 1
open fun isIndeterminate(): Boolean

Indicate whether this progress bar is in indeterminate mode.

Return
Boolean true if the progress bar is in indeterminate mode

jumpDrawablesToCurrentState

Added in API level 11
open fun jumpDrawablesToCurrentState(): Unit

onRestoreInstanceState

Added in API level 1
open fun onRestoreInstanceState(state: Parcelable!): Unit
Parameters
state Parcelable!: The frozen state that had previously been returned by onSaveInstanceState.

onSaveInstanceState

Added in API level 1
open fun onSaveInstanceState(): Parcelable?
Return
Parcelable? Returns a Parcelable object containing the view's current dynamic state, or null if there is nothing interesting to save.

onVisibilityAggregated

Added in API level 24
open fun onVisibilityAggregated(isVisible: Boolean): Unit
Parameters
isVisible Boolean: true if this view and all of its ancestors are VISIBLE and this view's window is also visible

postInvalidate

Added in API level 1
open fun postInvalidate(): Unit

setIndeterminate

Added in API level 1
open fun setIndeterminate(indeterminate: Boolean): Unit

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.
Parameters
indeterminate Boolean: true to enable the indeterminate mode

setIndeterminateDrawable

Added in API level 1
open fun setIndeterminateDrawable(d: Drawable!): Unit

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

For the Drawable to animate, it must implement Animatable, or override Drawable#onLevelChange(int). A Drawable that implements Animatable will be animated via that interface and therefore provides the greatest amount of customization. A Drawable that only overrides onLevelChange(int) is animated directly by ProgressBar and only the animation duration, repeating behavior, and interpolator can be modified, and only before the indeterminate animation begins.

Parameters
d Drawable!: the new drawable

setIndeterminateDrawableTiled

Added in API level 21
open fun setIndeterminateDrawableTiled(d: Drawable!): Unit

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

If the drawable is a BitmapDrawable or contains BitmapDrawables, a tiled copy will be generated for display as a progress bar.

Parameters
d Drawable!: the new drawable

setIndeterminateTintBlendMode

Added in API level 29
open fun setIndeterminateTintBlendMode(blendMode: BlendMode?): Unit

Specifies the blending mode used to apply the tint specified by setIndeterminateTintList(android.content.res.ColorStateList) to the indeterminate drawable. The default mode is PorterDuff.Mode#SRC_IN.

Parameters
blendMode BlendMode?: the blending mode used to apply the tint, may be null to clear tint

setIndeterminateTintList

Added in API level 21
open fun setIndeterminateTintList(tint: ColorStateList?): Unit

Applies a tint to the indeterminate drawable. Does not modify the current tint mode, which is PorterDuff.Mode#SRC_IN by default.

Subsequent calls to setIndeterminateDrawable(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable#setTintList(ColorStateList).

Parameters
tint ColorStateList?: the tint to apply, may be null to clear tint

setIndeterminateTintMode

Added in API level 21
open fun setIndeterminateTintMode(tintMode: PorterDuff.Mode?): Unit

Specifies the blending mode used to apply the tint specified by setIndeterminateTintList(android.content.res.ColorStateList) to the indeterminate drawable. The default mode is PorterDuff.Mode#SRC_IN.

Parameters
tintMode PorterDuff.Mode?: the blending mode used to apply the tint, may be null to clear tint

setInterpolator

Added in API level 1
open fun setInterpolator(
    context: Context!,
    resID: Int
): Unit

Sets the acceleration curve for the indeterminate animation.

The interpolator is loaded as a resource from the specified context. Defaults to a linear interpolation.

The interpolator only affects the indeterminate animation if the supplied indeterminate drawable does not implement Animatable.

This call must be made before the indeterminate animation starts for it to have an affect.

Parameters
context Context!: The application environment
resID Int: The resource identifier of the interpolator to load

setInterpolator

Added in API level 1
open fun setInterpolator(interpolator: Interpolator!): Unit

Sets the acceleration curve for the indeterminate animation. Defaults to a linear interpolation.

The interpolator only affects the indeterminate animation if the supplied indeterminate drawable does not implement Animatable.

This call must be made before the indeterminate animation starts for it to have an affect.

Parameters
interpolator Interpolator!: The interpolator which defines the acceleration curve

setMax

Added in API level 1
open fun setMax(max: Int): Unit

Set the upper range of the progress bar max.

Parameters
max Int: the upper range of this progress bar

setMaxHeight

Added in API level 29
open fun setMaxHeight(maxHeight: Int): Unit

Sets the maximum height the progress bar can have.

Parameters
maxHeight Int: the maximum height to be set, in pixels The units of this value are pixels.

setMaxWidth

Added in API level 29
open fun setMaxWidth(maxWidth: Int): Unit

Sets the maximum width the progress bar can have.

Parameters
maxWidth Int: the maximum width to be set, in pixels The units of this value are pixels.

setMin

Added in API level 26
open fun setMin(min: Int): Unit

Set the lower range of the progress bar to min.

Parameters
min Int: the lower range of this progress bar

setMinHeight

Added in API level 29
open fun setMinHeight(minHeight: Int): Unit

Sets the minimum height the progress bar can have.

Parameters
minHeight Int: the minimum height to be set, in pixels The units of this value are pixels.

setMinWidth

Added in API level 29
open fun setMinWidth(minWidth: Int): Unit

Sets the minimum width the progress bar can have.

Parameters
minWidth Int: the minimum width to be set, in pixels The units of this value are pixels.

setProgress

Added in API level 1
open fun setProgress(progress: Int): Unit

Sets the current progress to the specified value. Does not do anything if the progress bar is in indeterminate mode.

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

Parameters
progress Int: the new progress, between getMin() and getMax()

setProgress

Added in API level 24
open fun setProgress(
    progress: Int,
    animate: Boolean
): Unit

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

Animation does not affect the result of getProgress(), which will return the target value immediately after this method is called.

Parameters
progress Int: the new progress value, between getMin() and getMax()
animate Boolean: true to animate between the current and target values or false to not animate

setProgressBackgroundTintBlendMode

Added in API level 29
open fun setProgressBackgroundTintBlendMode(blendMode: BlendMode?): Unit

Specifies the blending mode used to apply the tint specified by setProgressBackgroundTintList(android.content.res.ColorStateList)} to the progress background. The default mode is BlendMode#SRC_IN.

Parameters
blendMode BlendMode?: the blending mode used to apply the tint, may be null to clear tint

setProgressBackgroundTintList

Added in API level 21
open fun setProgressBackgroundTintList(tint: ColorStateList?): Unit

Applies a tint to the progress background, if one exists. Does not modify the current tint mode, which is 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(android.graphics.drawable.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).

Parameters
tint ColorStateList?: the tint to apply, may be null to clear tint

setProgressBackgroundTintMode

Added in API level 21
open fun setProgressBackgroundTintMode(tintMode: PorterDuff.Mode?): Unit

Specifies the blending mode used to apply the tint specified by setProgressBackgroundTintList(android.content.res.ColorStateList)} to the progress background. The default mode is PorterDuff.Mode#SRC_IN.

Parameters
tintMode PorterDuff.Mode?: the blending mode used to apply the tint, may be null to clear tint

setProgressDrawable

Added in API level 1
open fun setProgressDrawable(d: Drawable!): Unit

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

Parameters
d Drawable!: the new drawable

setProgressDrawableTiled

Added in API level 21
open fun setProgressDrawableTiled(d: Drawable!): Unit

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

If the drawable is a BitmapDrawable or contains BitmapDrawables, a tiled copy will be generated for display as a progress bar.

Parameters
d Drawable!: the new drawable

setProgressTintBlendMode

Added in API level 29
open fun setProgressTintBlendMode(blendMode: BlendMode?): Unit

Specifies the blending mode used to apply the tint specified by setProgressTintList(android.content.res.ColorStateList)} to the progress indicator. The default mode is PorterDuff.Mode#SRC_IN.

Parameters
blendMode BlendMode?: the blending mode used to apply the tint, may be null to clear tint

setProgressTintList

Added in API level 21
open fun setProgressTintList(tint: ColorStateList?): Unit

Applies a tint to the progress indicator, if one exists, or to the entire progress drawable otherwise. Does not modify the current tint mode, which is 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(android.graphics.drawable.Drawable) will automatically mutate the drawable and apply the specified tint and tint mode using Drawable#setTintList(ColorStateList).

Parameters
tint ColorStateList?: the tint to apply, may be null to clear tint

setProgressTintMode

Added in API level 21
open fun setProgressTintMode(tintMode: PorterDuff.Mode?): Unit

Specifies the blending mode used to apply the tint specified by setProgressTintList(android.content.res.ColorStateList)} to the progress indicator. The default mode is PorterDuff.Mode#SRC_IN.

Parameters
tintMode PorterDuff.Mode?: the blending mode used to apply the tint, may be null to clear tint

setSecondaryProgress

Added in API level 1
open fun setSecondaryProgress(secondaryProgress: Int): Unit

Set the current secondary progress to the specified value. Does not do anything if the progress bar is in indeterminate mode.

Parameters
secondaryProgress Int: the new secondary progress, between getMin() and getMax()

setSecondaryProgressTintBlendMode

Added in API level 29
open fun setSecondaryProgressTintBlendMode(blendMode: BlendMode?): Unit

Specifies the blending mode used to apply the tint specified by setSecondaryProgressTintList(android.content.res.ColorStateList)} to the secondary progress indicator. The default mode is PorterDuff.Mode#SRC_ATOP.

Parameters
blendMode BlendMode?: the blending mode used to apply the tint, may be null to clear tint

setSecondaryProgressTintList

Added in API level 21
open fun setSecondaryProgressTintList(tint: ColorStateList?): Unit

Applies a tint to the secondary progress indicator, if one exists. Does not modify the current tint mode, which is 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(android.graphics.drawable.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).

Parameters
tint ColorStateList?: the tint to apply, may be null to clear tint

setSecondaryProgressTintMode

Added in API level 21
open fun setSecondaryProgressTintMode(tintMode: PorterDuff.Mode?): Unit

Specifies the blending mode used to apply the tint specified by setSecondaryProgressTintList(android.content.res.ColorStateList)} to the secondary progress indicator. The default mode is PorterDuff.Mode#SRC_ATOP.

Parameters
tintMode PorterDuff.Mode?: the blending mode used to apply the tint, may be null to clear tint

setStateDescription

Added in API level 30
open fun setStateDescription(stateDescription: CharSequence?): Unit

This function is called when an instance or subclass sets the state description. Once this is called and the argument is not null, the app developer will be responsible for updating state description when progress changes and the default state description will not be used. App developers can restore the default behavior by setting the argument to null. If set progress is called first and then setStateDescription is called, two state change events will be merged by event throttling and we can still get the correct state description.

Parameters
stateDescription CharSequence?: The state description. This value may be null.

Protected methods

drawableStateChanged

Added in API level 1
protected open fun drawableStateChanged(): Unit

onAttachedToWindow

Added in API level 1
protected open fun onAttachedToWindow(): Unit

onDetachedFromWindow

Added in API level 1
protected open fun onDetachedFromWindow(): Unit

onDraw

Added in API level 1
protected open fun onDraw(canvas: Canvas): Unit
Parameters
canvas Canvas: the canvas on which the background will be drawn This value cannot be null.

onMeasure

Added in API level 1
protected open fun onMeasure(
    widthMeasureSpec: Int,
    heightMeasureSpec: Int
): Unit
Parameters
widthMeasureSpec Int: horizontal space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.
heightMeasureSpec Int: vertical space requirements as imposed by the parent. The requirements are encoded with android.view.View.MeasureSpec.

onSizeChanged

Added in API level 1
protected open fun onSizeChanged(
    w: Int,
    h: Int,
    oldw: Int,
    oldh: Int
): Unit
Parameters
w Int: Current width of this view.
h Int: Current height of this view.
oldw Int: Old width of this view.
oldh Int: Old height of this view.

verifyDrawable

Added in API level 1
protected open fun verifyDrawable(who: Drawable): 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. This allows animations for those drawables to be scheduled.

Be sure to call through to the super class when overriding this function.
If you override this method you must call through to the superclass implementation.

Parameters
who Drawable: This value cannot be null.
Return
Boolean boolean If true then the Drawable is being displayed in the view; else false and it is not allowed to animate.