Todd-Davies / ProgressWheel

A progress wheel for android, intended for use instead of the standard progress bar.
MIT License
2.64k stars 710 forks source link

Text with multiple line doesn't work #60

Open arnaudbarbe opened 9 years ago

arnaudbarbe commented 9 years ago

create an ProgressWheel and setText with \n lines overlap

arnaudbarbe commented 9 years ago

try this in ProgressWheel.java

protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    //Draw the inner circle
    canvas.drawArc(innerCircleBounds, 360, 360, false, circlePaint);
    //Draw the rim
    canvas.drawArc(circleBounds, 360, 360, false, rimPaint);
    canvas.drawArc(circleOuterContour, 360, 360, false, contourPaint);
    //canvas.drawArc(circleInnerContour, 360, 360, false, contourPaint);
    //Draw the bar
    if (isSpinning) {
        canvas.drawArc(circleBounds, progress - 90, barLength, false, barPaint);
    } else {
        canvas.drawArc(circleBounds, -90, progress, false, barPaint);
    }
    //Draw the text (attempts to center it horizontally and vertically)
    float textHeight = textPaint.descent() - textPaint.ascent();

    float startingOffset = (textHeight * splitText.length) / 2 - (textHeight / 4);

    for (int i = (splitText.length - 1) ; i >=0  ; i--) {
        float horizontalTextOffset = textPaint.measureText(splitText[i]) / 2;
        canvas.drawText(
                splitText[i],
                this.getWidth() / 2 - horizontalTextOffset,
                this.getHeight() / 2 + startingOffset,
                textPaint);

                startingOffset = startingOffset - textHeight;
    }
    if (isSpinning) {
        scheduleRedraw();
    }
}
Todd-Davies commented 9 years ago

I believe this is related to 57b1075.

narimetisaigopi commented 5 years ago

have you solved this problem?

narimetisaigopi commented 5 years ago

i did not get any official support from team. i created custom view with progresswheel it has worked for me check that code here https://pastebin.com/FZ0YSxSe