Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- protected synchronized void onDraw(Canvas canvas) {
- canvas.rotate(-90);
- canvas.translate(-getHeight(), 0);
- super.onDraw(canvas);
- String progressText = String.valueOf(getProgress());
- Rect bounds = new Rect();
- mTextPaint.getTextBounds(progressText, 0, progressText.length(), bounds);
- int leftPadding = getPaddingLeft() - getThumbOffset();
- int rightPadding = getPaddingRight() - getThumbOffset();
- int width = getWidth() - leftPadding - rightPadding;
- float progressRatio = (float) getProgress() / getMax();
- float thumbOffset = mThumbSize * (.5f - progressRatio);
- float thumbX = progressRatio * width + leftPadding + thumbOffset;
- float thumbY = getHeight() / 2f + bounds.height() / 2f;
- canvas.drawText(progressText, thumbX, thumbY, mTextPaint);
- canvas.rotate(90);
- }
Add Comment
Please, Sign In to add comment