jakob-grabner / Circle-Progress-View

Animated circular progress view for Android
MIT License
1.32k stars 242 forks source link

Text position on re-layout #38

Open gxcare opened 8 years ago

gxcare commented 8 years ago

After changing the view size due to a re-layout the text is no longer centered.

galexant commented 8 years ago

Hi. I just add one line in onDraw method before drawing spinner:

        triggerReCalcTextSizesAndPositions();

        //Draw spinner
        if (mAnimationState == Attributes.AnimationState.SPINNING || mAnimationState == Attributes.AnimationState.END_SPINNING) {
            drawSpinner(canvas);
            if (mShowTextWhileSpinning) {
                drawTextWithUnit(canvas);
            }

        } else if (mAnimationState == Attributes.AnimationState.END_SPINNING_START_ANIMATING) {
            //draw spinning arc
            drawSpinner(canvas);

            if (mDrawBarWhileSpinning) {
                drawBar(canvas, degrees);
                drawTextWithUnit(canvas);
            } else if (mShowTextWhileSpinning) {
                drawTextWithUnit(canvas);
            }

        } else {
            drawBar(canvas, degrees);
            drawTextWithUnit(canvas);
        }