# RoundCornerProgressBar — Android View The Android View implementation of RoundCornerProgressBar. See the [project README](../README.md) for the library overview, and the [Jetpack Compose module](../compose/README.md) for the Compose implementation. # Download ```kotlin implementation("com.akexorcist:roundcornerprogressbar-view:2.3.0") ``` > Previously published as `com.akexorcist:round-corner-progress-bar`. See [Migration](../README.md#migration) for the artifact rename. # Usage For using custom attribute of progress bar, define 'app' namespace as root view attribute in your layout ```xml xmlns:app="http://schemas.android.com/apk/res-auto" ``` ## RoundCornerProgressBar ### Example ```xml ``` ![Round Corner Progress Bar](../image/sample_simple.jpg) ### Layout XML ```xml ``` ### Public Methods ```kotlin // Progress fun getMax(): Float fun setMax(max: Float) fun setMax(max: Int) fun getProgress(): Float fun setProgress(progress: Int) fun setProgress(progress: Float) fun getSecondaryProgress(): Float fun setSecondaryProgress(secondaryProgress: Int) fun setSecondaryProgress(secondaryProgress: Float) // Dimension fun getRadius(): Int fun setRadius(radius: Int) fun getPadding(): Int fun setPadding(padding: Int) fun getLayoutWidth(): Float // Animation fun enableAnimation() fun disableAnimation() fun getAnimationSpeedScale(): Float fun setAnimationSpeedScale(scale: Float) fun isProgressAnimating(): Boolean fun isSecondaryProgressAnimating(): Boolean // Reversing Progress fun isReverse(): Boolean fun setReverse(isReverse: Boolean) // Color fun getProgressBackgroundColor(): Int fun setProgressBackgroundColor(color: Int) fun getProgressColor(): Int fun setProgressColor(color: Int) fun getProgressColors(): List fun setProgressColors(colors: List) fun getSecondaryProgressColor(): Int fun setSecondaryProgressColor(color: Int) fun getSecondaryProgressColors(): List fun setSecondaryProgressColors(colors: List) // Listener fun setOnProgressChangedListener(listener: OnProgressChangedListener) ``` ## CenteredRoundCornerProgressBar Same as RoundCornerProgressBar but reversing does not supported. ### Example ```xml ``` ![Centerd Round Corner Progress Bar](../image/sample_centered.jpg) ### Layout XML ```xml ``` ### Public Methods ```kotlin // Progress fun getMax(): Float fun setMax(max: Float) fun setMax(max: Int) fun getProgress(): Float fun setProgress(progress: Int) fun setProgress(progress: Float) fun getSecondaryProgress(): Float fun setSecondaryProgress(secondaryProgress: Int) fun setSecondaryProgress(secondaryProgress: Float) // Dimension fun getRadius(): Int fun setRadius(radius: Int) fun getPadding(): Int fun setPadding(padding: Int) fun getLayoutWidth(): Float // Animation fun enableAnimation() fun disableAnimation() fun getAnimationSpeedScale(): Float fun setAnimationSpeedScale(scale: Float) fun isProgressAnimating(): Boolean fun isSecondaryProgressAnimating(): Boolean // Color fun getProgressBackgroundColor(): Int fun setProgressBackgroundColor(color: Int) fun getProgressColor(): Int fun setProgressColor(color: Int) fun getProgressColors(): List fun setProgressColors(colors: List) fun getSecondaryProgressColor(): Int fun setSecondaryProgressColor(color: Int) fun getSecondaryProgressColors(): List fun setSecondaryProgressColors(colors: List) // Listener fun setOnProgressChangedListener(listener: OnProgressChangedListener) ``` ## IconRoundCornerProgressBar Icon size is required for this progress bar. Use `wrap_content` for `layout_height` is recommended. ```xml ``` ### Example ```xml ``` ![Icon Round Corner Progress Bar](../image/sample_icon.jpg) ### Layout XML ```xml ``` ### Public Methods ```kotlin // Progress fun getMax(): Float fun setMax(max: Float) fun setMax(max: Int) fun getProgress(): Float fun setProgress(progress: Int) fun setProgress(progress: Float) fun getSecondaryProgress(): Float fun setSecondaryProgress(secondaryProgress: Int) fun setSecondaryProgress(secondaryProgress: Float) // Dimension fun getRadius(): Int fun setRadius(radius: Int) fun getPadding(): Int fun setPadding(padding: Int) fun getLayoutWidth(): Float fun getIconSize(): Int fun setIconSize(size: Int) fun getIconPadding(): Int fun setIconPadding(padding: Int) fun getIconPaddingLeft(): Int fun setIconPaddingLeft(padding: Int) fun getIconPaddingTop(): Int fun setIconPaddingTop(padding: Int) fun getIconPaddingRight(): Int fun setIconPaddingRight(padding: Int) fun getIconPaddingBottom(): Int fun setIconPaddingBottom(padding: Int) // Animation fun enableAnimation() fun disableAnimation() fun getAnimationSpeedScale(): Float fun setAnimationSpeedScale(scale: Float) fun isProgressAnimating(): Boolean fun isSecondaryProgressAnimating(): Boolean // Reversing Progress fun isReverse(): Boolean fun setReverse(isReverse: Boolean) // Color fun getProgressBackgroundColor(): Int fun setProgressBackgroundColor(color: Int) fun getProgressColor(): Int fun setProgressColor(color: Int) fun getProgressColors(): List fun setProgressColors(colors: List) fun getSecondaryProgressColor(): Int fun setSecondaryProgressColor(color: Int) fun getSecondaryProgressColors(): List fun setSecondaryProgressColors(colors: List) fun getColorIconBackground(): Int fun setIconBackgroundColor(color: Int) // Icon fun getIconImageResource(): Int fun setIconImageResource(resId: Int) fun getIconImageBitmap(): Birmap fun setIconImageBitmap(bitmap: Bitmap) fun getIconImageDrawable(): Drawable fun setIconImageDrawable(drawable: Drawable) // Listener fun setOnProgressChangedListener(listener: OnProgressChangedListener) fun setOnIconClickListener(listener: OnIconClickListener) ``` ## TextRoundCornerProgressBar ### Example ```xml ``` ![Text Round Corner Progress Bar](../image/sample_text.jpg) ### Layout XML ```xml ``` ### Public Methods ```kotlin // Progress fun getMax(): Float fun setMax(max: Float) fun setMax(max: Int) fun getProgress(): Float fun setProgress(progress: Int) fun setProgress(progress: Float) fun getSecondaryProgress(): Float fun setSecondaryProgress(secondaryProgress: Int) fun setSecondaryProgress(secondaryProgress: Float) // Dimension fun getRadius(): Int fun setRadius(radius: Int) fun getPadding(): Int fun setPadding(padding: Int) fun getLayoutWidth(): Float fun getTextProgressSize(): Int fun setTextProgressSize(size: Int) fun getTextProgressMargin(): Int fun setTextProgressMargin(margin: Int) // Animation fun enableAnimation() fun disableAnimation() fun getAnimationSpeedScale(): Float fun setAnimationSpeedScale(scale: Float) fun isProgressAnimating(): Boolean fun isSecondaryProgressAnimating(): Boolean // Reversing Progress fun isReverse(): Boolean fun setReverse(isReverse: Boolean) // Color fun getProgressBackgroundColor(): Int fun setProgressBackgroundColor(color: Int) fun getProgressColor(): Int fun setProgressColor(color: Int) fun getProgressColors(): List fun setProgressColors(colors: List) fun getSecondaryProgressColor(): Int fun setSecondaryProgressColor(color: Int) fun getSecondaryProgressColors(): List fun setSecondaryProgressColors(colors: List) fun getTextProgressColor(): Int fun setTextProgressColor(color: Int) // Text fun getProgressText(): String fun setProgressText(text: String) // Position fun getTextPositionPriority(): Int fun setTextPositionPriority(priority: Int) fun getTextInsideGravity(): Int fun setTextInsideGravity(gravity: Int) fun getTextOutsideGravity(): Int fun setTextOutsideGravity(gravity: Int) // Listener fun setOnProgressChangedListener(listener: OnProgressChangedListener) ``` ## IndeterminateRoundCornerProgressBar ### Example ```xml ``` ![Indeterminate Round Corner Progress Bar](../image/sample_indeterminate.gif) ### Layout XML ```xml ``` ### Public Methods ```kotlin // Dimension fun getRadius(): Int fun setRadius(radius: Int) fun getPadding(): Int fun setPadding(padding: Int) fun getLayoutWidth(): Float // Animation fun getAnimationSpeedScale(): Float fun setAnimationSpeedScale(scale: Float) // Reversing Progress fun isReverse(): Boolean fun setReverse(isReverse: Boolean) // Color fun getProgressBackgroundColor(): Int fun setProgressBackgroundColor(color: Int) fun getProgressColor(): Int fun setProgressColor(color: Int) fun getProgressColors(): List fun setProgressColors(colors: List) fun getSecondaryProgressColor(): Int fun setSecondaryProgressColor(color: Int) fun getSecondaryProgressColors(): List fun setSecondaryProgressColors(colors: List) ``` ## IndeterminateCenteredRoundCornerProgressBar Same as IndeterminateRoundCornerProgressBar ### Example ```xml ``` ![Indeterminate Centered Round Corner Progress Bar](../image/sample_indeterminate_centered.gif) ### Layout XML ```xml ``` ### Public Methods ```kotlin // Dimension fun getRadius(): Int fun setRadius(radius: Int) fun getPadding(): Int fun setPadding(padding: Int) fun getLayoutWidth(): Float // Animation fun getAnimationSpeedScale(): Float fun setAnimationSpeedScale(scale: Float) // Reversing Progress fun isReverse(): Boolean fun setReverse(isReverse: Boolean) // Color fun getProgressBackgroundColor(): Int fun setProgressBackgroundColor(color: Int) fun getProgressColor(): Int fun setProgressColor(color: Int) fun getProgressColors(): List fun setProgressColors(colors: List) fun getSecondaryProgressColor(): Int fun setSecondaryProgressColor(color: Int) fun getSecondaryProgressColors(): List fun setSecondaryProgressColors(colors: List) ``` ## Apply Gradient Progress Bar Color Gradient color for progress bar must be in int array resource. At least 2 colors. ```xml #009688 #80CBC4 ``` ![Gradient Progress Bar Color](../image/sample_gradient.jpg) Progress bar does not clipped when size changed. So the gradient color will fully display without clipping also. ## Apply Progress Change Animation Animation when progress change is disabled by default (exclude `IndeterminateProgressBar` and `IndeterminateCenteredProgressBar`). So you have to enable the animation by XML attribute or programmatically ```xml ``` When progress changed, the animation will applied automatically. ![Comparison Between With/Without Animation](../image/animation_comparison.gif) Animation speed scale's value is float between 0.2 - 5.0 (default is 1.0). Higher for slow down the animation, lower for speed up. # What's Next - IconTextRoundCornerProgressBar ([#69](https://github.com/akexorcist/Android-RoundCornerProgressBar/pull/69)) - UI Preview improvement # Known Issues - Incorrect progress showing in `CenteredRoundCornerProgressBar` with 1%-2% value - Incorrect text's width in `TextRoundCornerProgressBar` when `outside` priority and value close to 100% - `setProgress(progress: Int)` does not update text position