CircularProgressIndicator

public final class CircularProgressIndicator
extends BaseProgressIndicator<CircularProgressIndicatorSpec>

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.ProgressBar
       ↳ com.google.android.material.progressindicator.BaseProgressIndicator<com.google.android.material.progressindicator.CircularProgressIndicatorSpec>
         ↳ com.google.android.material.progressindicator.CircularProgressIndicator


This class implements the circular type progress indicators.

With the default style R.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.

Summary

Constants

int INDICATOR_DIRECTION_CLOCKWISE

int INDICATOR_DIRECTION_COUNTERCLOCKWISE

Inherited constants

Fields

public static final int DEF_STYLE_RES

Inherited fields

Public constructors

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

Public methods

int getIndicatorDirection()

Returns the indicator animating direction used in this progress indicator.

int getIndicatorInset()

Returns the inset of this progress indicator.

int getIndicatorSize()

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

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 methods

Constants

INDICATOR_DIRECTION_CLOCKWISE

public static final int INDICATOR_DIRECTION_CLOCKWISE

Constant Value: 0 (0x00000000)

INDICATOR_DIRECTION_COUNTERCLOCKWISE

public static final int INDICATOR_DIRECTION_COUNTERCLOCKWISE

Constant Value: 1 (0x00000001)

Fields

DEF_STYLE_RES

public static final int DEF_STYLE_RES

Public constructors

CircularProgressIndicator

public CircularProgressIndicator (Context context)

Parameters
context Context

CircularProgressIndicator

public CircularProgressIndicator (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CircularProgressIndicator

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

Parameters
context Context

attrs AttributeSet

defStyleAttr int

Public methods

getIndicatorDirection

public int getIndicatorDirection ()

Returns the indicator animating direction used in this progress indicator.

Returns
int

getIndicatorInset

public int getIndicatorInset ()

Returns the inset of this progress indicator.

Returns
int

getIndicatorSize

public int getIndicatorSize ()

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

Returns
int

setIndicatorDirection

public void setIndicatorDirection (int indicatorDirection)

Sets the indicator animating direction used in this progress indicator.

Parameters
indicatorDirection int: The new indicator direction.

setIndicatorInset

public void setIndicatorInset (int indicatorInset)

Sets the inset of this progress indicator.

Parameters
indicatorInset int: The new inset in pixels.

setIndicatorSize

public void setIndicatorSize (int indicatorSize)

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

Parameters
indicatorSize int: The new size in pixels.

Throws
IllegalArgumentException if new indicator radius is less than half of the indicator size.

See also:

setTrackThickness

public void setTrackThickness (int trackThickness)

Sets the track thickness of this progress indicator.

Parameters
trackThickness int: The new track/indicator thickness in pixel.

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