Android 12 Developer Preview is here! Try it out, and give us your feedback!

CircularProgressDrawable

open class CircularProgressDrawable : Drawable, Animatable
kotlin.Any
   ↳ android.graphics.drawable.Drawable
   ↳ androidx.swiperefreshlayout.widget.CircularProgressDrawable

Drawable that renders the animated indeterminate progress indicator in the Material design style without depending on API level 11.

While this may be used to draw an indeterminate spinner using start() and methods, this may also be used to draw a progress arc using method. CircularProgressDrawable also supports adding an arrow at the end of the arc by setArrowEnabled(boolean) and setArrowDimensions(float, * float) methods.

To use one of the pre-defined sizes instead of using your own, setStyle(int) should be called with one of the DEFAULT or LARGE styles as its parameter. Doing it so will update the arrow dimensions, ring size and stroke width to fit the one specified.

If no center radius is set via setCenterRadius(float) or setStyle(int) methods, CircularProgressDrawable will fill the bounds set via setBounds(Rect).

Summary

Constants
static Int

Maps to ProgressBar default style.

static Int

Maps to ProgressBar.

Public constructors
<init>(@NonNull context: Context)

Public methods
open Unit
draw(canvas: Canvas)

open Int

open Boolean

Returns true if the arrow at the end of the spinner is shown.

open Float

Returns the arrow height in pixels.

open Float

Returns the scale of the arrow at the end of the spinner.

open Float

Returns the arrow width in pixels.

open Int

Returns the background color of the circle drawn inside the drawable.

open Float

Returns the center radius for the progress spinner in pixels.

open IntArray

Returns the colors used in the progress animation

open Float

Returns the end trim for the progress spinner arc

open Int

open Float

Returns the amount of rotation applied to the progress spinner.

open Float

Returns the start trim for the progress spinner arc

open Cap

Returns the stroke cap of the progress spinner.

open Float

Returns the stroke width for the progress spinner in pixels.

open Boolean

open Unit
setAlpha(alpha: Int)

open Unit
setArrowDimensions(width: Float, height: Float)

Sets the dimensions of the arrow at the end of the spinner in pixels.

open Unit

Sets if the arrow at the end of the spinner should be shown.

open Unit

Sets the scale of the arrow at the end of the spinner.

open Unit

Sets the background color of the circle inside the drawable.

open Unit
setCenterRadius(centerRadius: Float)

Sets the center radius for the progress spinner in pixels.

open Unit
setColorFilter(colorFilter: ColorFilter?)

open Unit
setColorSchemeColors(@NonNull vararg colors: Int)

Sets the colors used in the progress animation from a color list.

open Unit

Sets the amount of rotation to apply to the progress spinner.

open Unit
setStartEndTrim(start: Float, end: Float)

Sets the start and end trim for the progress spinner arc.

open Unit
setStrokeCap(@NonNull strokeCap: Cap)

Sets the stroke cap of the progress spinner.

open Unit
setStrokeWidth(strokeWidth: Float)

Sets the stroke width for the progress spinner in pixels.

open Unit
setStyle(size: Int)

Sets the overall size for the progress spinner.

open Unit

Starts the animation for the spinner.

open Unit

Stops the animation for the spinner.

Constants

DEFAULT

static val DEFAULT: Int

Maps to ProgressBar default style.

Value: 1

LARGE

static val