CircularProgressIndicator

public class CircularProgressIndicator extends BaseProgressIndicator


This class implements the circular type progress indicators.

With the default style Widget.MaterialComponents.CircularProgressIndicator, 4dp indicator/track thickness is used without animation for visibility change. Without customization, primaryColor will be used as the indicator color; the track is transparent. The following attributes can be used to customize the component's appearance:

  • trackThickness: the thickness of the indicator and track.
  • indicatorColor: the color(s) of the indicator.
  • trackColor: the color of the track.
  • trackCornerRadius: the radius of the rounded corner of the indicator and track.
  • indicatorSize: the outer diameter of the spinner.
  • indicatorInset: the inset from component's bound to the spinner's outer edge.
  • indicatorDirectionCircular: the rotation direction of the spinner or indicator.

For more information, see the component developer guidance and design guidelines.

Summary

Constants

static final int
static final int

Used in the indeterminate animation type setter for advance animation, which animates an active segment to iteratively grow by modifying the end position and shrink by modifying the start position.

static final int

Used in the indeterminate animation type setter for retreat animation, which animates an active segment to iteratively grow and shrink by modifying the end position.

static final int
static final int

Public constructors

CircularProgressIndicator(Context context)
CircularProgressIndicator(Context context, AttributeSet attrs)
CircularProgressIndicator(
    Context context,
    AttributeSet attrs,
    int defStyleAttr
)

Public methods

int

Returns the type of indeterminate animation of this progress indicator.

int

Returns the indicator animating direction used in this progress indicator.

int

Returns the inset of this progress indicator.

int

Returns the size (outer diameter) of this progress indicator.

void
setIndeterminateAnimationType(int indeterminateAnimationType)

Sets the type of indeterminate animation.

void
setIndicatorDirection(int indicatorDirection)

Sets the indicator animating direction used in this progress indicator.

void
setIndicatorInset(int indicatorInset)

Sets the inset of this progress indicator.

void
setIndicatorSize(int indicatorSize)

Sets the size (outer diameter) of this circular progress indicator.

void
setTrackThickness(int trackThickness)

Sets the track thickness of this progress indicator.

Inherited Constants

From com.google.android.material.progressindicator.BaseProgressIndicator
static final int
static final int
static final int
static final int
static final int
static final int
static final int

Inherited methods

From com.google.android.material.progressindicator.BaseProgressIndicator
void
applyNewVisibility(boolean animate)

If it changes to visible, the start animation will be started if showAnimationBehavior indicates any.

Drawable

Returns the corresponding drawable based on current indeterminate state.

int

Returns the hide animation behavior used in this progress indicator.

IndeterminateDrawable<S>
int[]

Returns the array of colors used in the indicator of this progress indicator.

int

Returns the size of the gap between the indicator and track in pixels.

DeterminateDrawable<S>
int

Returns the show animation behavior used in this progress indicator.

int

Returns the color used in the track of this progress indicator.

int

Returns the radius of the rounded corner for the indicator and track in pixels.

float

Returns the relative radius of the rounded corner for the indicator and track in pixels.

int

Returns the track thickness of this progress indicator in pixels.

int

Returns the amplitude of the indicator's amplitude in pixels.

int

Returns the speed of the indicator's waveform in pixels.

int

Returns the wavelength, in pixels, of the indicator's waveform in determinate mode.

int

Returns the wavelength, in pixels, of the indicator's waveform in indeterminate mode.

void

Hides the progress indicator.

void
void
void
synchronized void
onDraw(Canvas canvas)
void
onLayout(boolean changed, int left, int top, int right, int bottom)
synchronized void
onMeasure(int widthMeasureSpec, int heightMeasureSpec)
void
onVisibilityChanged(View changedView, int visibility)
void
onWindowVisibilityChanged(int visibility)
void
setHideAnimationBehavior(int hideAnimationBehavior)

Sets the hide animation behavior used in this progress indicator.

synchronized void
setIndeterminate(boolean indeterminate)

Sets the progress mode of the progress indicator.

void
setIndeterminateAnimatorDurationScale(
    float indeterminateAnimatorDurationScale
)

Sets the scale of the animation duration in indeterminate mode.

void
setIndeterminateDrawable(Drawable drawable)

Sets a new indeterminate drawable.

void
setIndicatorColor(int[] indicatorColors)

Sets the colors used in the indicator of this progress indicator.

void
setIndicatorTrackGapSize(int indicatorTrackGapSize)

Sets the size of the gap between the indicator and track in pixels.

synchronized void
setProgress(int progress)

Sets the current progress to the specified value.

void
setProgressCompat(int progress, boolean animated)

Sets the current progress to the specified value with/without animation based on the input.

void
setProgressDrawable(Drawable drawable)

Sets a new progress drawable.

void
setShowAnimationBehavior(int showAnimationBehavior)

Sets the show animation behavior used in this progress indicator.

void
setTrackColor(int trackColor)

Sets the color of the track of this progress indicator.

void
setTrackCornerRadius(int trackCornerRadius)

Sets the radius of the rounded corner for the indicator and track in pixels.

void

Sets the radius of the rounded corner for the indicator and track in fraction of track thickness.

void
setVisibilityAfterHide(int visibility)

Sets the visibility which the component will be after hide animation finishes.

void
setWaveAmplitude(int waveAmplitude)

Sets the amplitude of the indicator's amplitude in pixels.

void
setWaveSpeed(int waveSpeed)

Sets the speed of the indicator's waveform in pixels.

void
setWavelength(int wavelength)

Sets the wavelength of the indicator's determinate and indeterminate waveform in pixels.

void
setWavelengthDeterminate(int wavelength)

Sets the wavelength, in pixels, of the indicator's waveform in indeterminate mode.

void

Sets the wavelength, in pixels, of the indicator's waveform in indeterminate mode.

void

Shows the progress indicator.

Constants

DEF_STYLE_RES

public static final int DEF_STYLE_RES

INDETERMINATE_ANIMATION_TYPE_ADVANCE

public static final int INDETERMINATE_ANIMATION_TYPE_ADVANCE = 0

Used in the indeterminate animation type setter for advance animation, which animates an active segment to iteratively grow by modifying the end position and shrink by modifying the start position.

INDETERMINATE_ANIMATION_TYPE_RETREAT

public static final int INDETERMINATE_ANIMATION_TYPE_RETREAT = 1

Used in the indeterminate animation type setter for retreat animation, which animates an active segment to iteratively grow and shrink by modifying the end position.

INDICATOR_DIRECTION_CLOCKWISE

public static final int INDICATOR_DIRECTION_CLOCKWISE = 0

INDICATOR_DIRECTION_COUNTERCLOCKWISE

public static final int INDICATOR_DIRECTION_COUNTERCLOCKWISE = 1

Public constructors

CircularProgressIndicator

public CircularProgressIndicator(Context context)

CircularProgressIndicator

public CircularProgressIndicator(Context context, AttributeSet attrs)

CircularProgressIndicator

public CircularProgressIndicator(
    Context context,
    AttributeSet attrs,
    int defStyleAttr
)

Public methods

getIndeterminateAnimationType

public int getIndeterminateAnimationType()

Returns the type of indeterminate animation of this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indeterminateAnimationType

getIndicatorDirection

public int getIndicatorDirection()

Returns the indicator animating direction used in this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indicatorDirectionCircular

getIndicatorInset

public int getIndicatorInset()

Returns the inset of this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indicatorInset

getIndicatorSize

public int getIndicatorSize()

Returns the size (outer diameter) of this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indicatorSize

See also
setIndicatorSize

setIndeterminateAnimationType

public void setIndeterminateAnimationType(int indeterminateAnimationType)

Sets the type of indeterminate animation.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indeterminateAnimationType

Parameters
int indeterminateAnimationType

The new type of indeterminate animation.

setIndicatorDirection

public void setIndicatorDirection(int indicatorDirection)

Sets the indicator animating direction used in this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indicatorDirectionCircular

Parameters
int indicatorDirection

The new indicator direction.

setIndicatorInset

public void setIndicatorInset(int indicatorInset)

Sets the inset of this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indicatorInset

Parameters
int indicatorInset

The new inset in pixels.

setIndicatorSize

public void setIndicatorSize(int indicatorSize)

Sets the size (outer diameter) of this circular progress indicator.

ref com.google.android.material.progressindicator.R.styleable#CircularProgressIndicator_indicatorSize

Parameters
int indicatorSize

The new size in pixels.

See also
getIndicatorSize

setTrackThickness

public void setTrackThickness(int trackThickness)

Sets the track thickness of this progress indicator.

ref com.google.android.material.progressindicator.R.styleable#BaseProgressIndicator_trackThickness

Parameters
int trackThickness

The new track/indicator thickness in pixel.

Throws
java.lang.IllegalArgumentException

if indicator size is less than twice of the track thickness.