Circular Progress Bar - Countdown

Reference: https://github.com/yanzhenjie/CircleTextProgressbar

 

However, this open source project cannot meet the project requirements. On this basis, it needs to be modified. The original author just regarded this as a progress bar, so he wrote 100 to death.

I modified it and can set any value. It can be used as a countdown, progress bar, 100-second countdown, 60-second countdown, or 100% progress bar

 

/**
     * Set progress.
     *
     * @param progress progress.
     */

    public void setMaxProgress(int maxProgress) {
        this.maxProgress = validateProgress(maxProgress);
        invalidate();
    }

     2. The key is to calculate how many parts the circle is divided into when drawing a circle, here 360/maxProgress, and then multiply the current progress progress

   @Override
    protected void onDraw(Canvas canvas)
{

    
 canvas.drawArc(mArcRect, 0, 360 * progress / maxProgress, false, mPaint);



}

 Above effect:

 

 

The modified code is in the attachment
 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326538108&siteId=291194637