@Override
  protected synchronized void onDraw(Canvas canvas) {
    canvas.drawArc(mCircleBounds, 0, 360, false, mBackgroundColorPaint);

    int prog = getProgress();
    float scale = getMax() > 0 ? (float) prog / getMax() * 360 : 0;

    if (mHasShadow) mProgressColorPaint.setShadowLayer(3, 0, 1, mShadowColor);
    canvas.drawArc(mCircleBounds, 270, scale, false, mProgressColorPaint);

    if (!TextUtils.isEmpty(mTitle)) {
      int xPos = (int) (getMeasuredWidth() / 2 - mTitlePaint.measureText(mTitle) / 2);
      int yPos = (int) (getMeasuredHeight() / 2);

      float titleHeight = Math.abs(mTitlePaint.descent() + mTitlePaint.ascent());
      if (TextUtils.isEmpty(mSubTitle)) {
        yPos += titleHeight / 2;
      }
      canvas.drawText(mTitle, xPos, yPos, mTitlePaint);

      yPos += titleHeight;
      xPos = (int) (getMeasuredWidth() / 2 - mSubtitlePaint.measureText(mSubTitle) / 2);

      canvas.drawText(mSubTitle, xPos, yPos, mSubtitlePaint);
    }

    super.onDraw(canvas);
  }
示例#2
0
 @Override
 protected void onDraw(Canvas canvas) {
   // Rotate the progress bar so that it draws vertically instead.
   canvas.save();
   canvas.rotate(-90, WIDTH / 2, WIDTH / 2);
   canvas.translate(-getHeight() + WIDTH, 0);
   super.onDraw(canvas);
   canvas.restore();
 }
 @Override
 protected synchronized void onDraw(Canvas canvas) {
   // First draw the regular progress bar, then custom draw our text
   super.onDraw(canvas);
   Rect bounds = new Rect();
   textPaint.getTextBounds(text, 0, text.length(), bounds);
   int x = getWidth() / 2 - bounds.centerX();
   int y = getHeight() / 2 - bounds.centerY();
   canvas.drawText(text, x, y, textPaint);
 }
 protected void onDraw(Canvas paramCanvas)
 {
   try
   {
     super.onDraw(paramCanvas);
     if ((isIndeterminate()) && ((getIndeterminateDrawable() instanceof d)) && (!((d)getIndeterminateDrawable()).isRunning())) {
       getIndeterminateDrawable().draw(paramCanvas);
     }
     return;
   }
   finally
   {
     paramCanvas = finally;
     throw paramCanvas;
   }
 }
 @Override
 protected synchronized void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   setpro();
   drawNinepath(canvas, rect);
 }