@Override
 protected void onDraw(Canvas canvas) {
   Drawable[] drawables = getCompoundDrawables();
   if (drawables != null) {
     Drawable drawableLeft = drawables[0];
     if (drawableLeft != null) {
       float textWidth = getPaint().measureText(getText().toString());
       if (textWidth == 0) {
         textWidth = getPaint().measureText(getHint().toString());
       }
       int drawablePadding = getCompoundDrawablePadding();
       int drawableWidth = 0;
       drawableWidth = drawableLeft.getIntrinsicWidth();
       float bodyWidth = textWidth + drawableWidth + drawablePadding;
       float middle = (getMeasuredWidth() - bodyWidth) / 2;
       //                if ((getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK) ==
       // Gravity.CENTER_HORIZONTAL){
       //                    middle =
       //                }
       if (middle > 0) {
         canvas.translate(middle, 0);
       }
     }
   }
   super.onDraw(canvas);
 }
示例#2
0
 @Override
 public void onDraw(Canvas canvas) {
   if (shimmerViewHelper != null) {
     shimmerViewHelper.onDraw();
   }
   super.onDraw(canvas);
 }
示例#3
0
 @Override
 protected void onDraw(Canvas canvas) {
   if (!isPaused) {
     setTimerText();
   }
   super.onDraw(canvas);
 }
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   text = super.getText().toString();
   xTextOffset = (getWidth() / 2) - (getPaint().measureText(text) / 2);
   yTextOffset = (getHeight() / 2) - (getPaint().ascent() / 2);
   canvas.drawText(text, xTextOffset, yTextOffset, mTextPaintOutline);
   canvas.drawText(text, xTextOffset, yTextOffset, mTextPaint);
 }
示例#5
0
  protected void onDraw(Canvas canvas) {

    // TODO Auto-generated method stub
    super.onDraw(canvas);

    if (!isMeasure) { // 文字宽度只需获取一次就可以了
      getTextWidth();
      isMeasure = true;
    }
  }
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   rectF.set(
       DEFAULT_STROKE_WIDTH / 2f,
       DEFAULT_STROKE_WIDTH / 2f,
       canvas.getWidth() - DEFAULT_STROKE_WIDTH / 2f,
       canvas.getHeight() - DEFAULT_STROKE_WIDTH / 2f);
   canvas.drawOval(rectF, paint);
 }
 @Override
 public void onDraw(@NonNull Canvas canvas) {
   if (mDrawCircle) {
     final int width = getWidth();
     final int height = getHeight();
     int radius = Math.min(width, height) / 2;
     canvas.drawCircle(width / 2, height / 2, radius, mCirclePaint);
   }
   setSelected(mDrawCircle);
   super.onDraw(canvas);
 }
示例#8
0
  @Override
  protected void onDraw(Canvas canvas) {

    if ((getGravity() & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.CENTER_VERTICAL) {
      if ((getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK) == Gravity.CENTER_HORIZONTAL) {
        super.onDraw(canvas);
      } else {
        final ColorStateList csl = getTextColors();
        final int color = csl.getDefaultColor();
        final int viewHeight = getHeight();
        final float textSize = getTextSize();
        final TextPaint paint = getPaint();
        paint.setColor(color);
        //		        Logger.d("TEXT", String.format("Padding: %d", getPaddingTop()));
        canvas.drawText(getText().toString(), 0, (viewHeight / 2 + textSize / 2), paint);
      }
    } else {
      super.onDraw(canvas);
    }
  }
示例#9
0
 @Override
 public void onDraw(Canvas canvas) {
   int height = getHeight();
   if (height <= 1) return;
   super.onDraw(canvas);
   if (getDrawingCacheBackgroundColor() != DragListView.DRAG_COLOR
       && getPaddingBottom() < getHeight() / 2) {
     // only draw divider when not dragging
     float h = height - 1;
     canvas.drawLine(0, h, getWidth(), h, mPaint);
   }
 }
示例#10
0
  @Override
  protected void onDraw(Canvas canvas) {
    // 倾斜45°,上下左右居中

    canvas.rotate(
        45, (int) ((float) getMeasuredWidth() / 1.44), (int) ((float) getMeasuredHeight() / 1.44));

    canvas.translate(
        -(int) ((float) getMeasuredHeight() / 3.7), (int) ((float) getMeasuredHeight() / 3.5));

    super.onDraw(canvas);
  }
 @Override
 protected void onDraw(Canvas canvas) {
   Drawable[] drawables = getCompoundDrawables();
   Drawable drawableRight = drawables[2];
   if (drawableRight != null) {
     float textWidth = getPaint().measureText(getText().toString());
     int drawablePadding = getCompoundDrawablePadding();
     int drawableWidth = drawableRight.getIntrinsicWidth();
     float bodyWidth = textWidth + drawableWidth + drawablePadding;
     setPadding(0, 0, (int) (getWidth() - bodyWidth), 0);
     canvas.translate((getWidth() - bodyWidth) / 2, 0);
   }
   super.onDraw(canvas);
 }
示例#12
0
  @Override
  protected void onDraw(Canvas canvas) {
    // 绘制外层矩形
    canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), mPaint1);
    // 绘制内层矩形
    canvas.drawRect(10, 10, getMeasuredWidth() - 10, getMeasuredHeight() - 10, mPaint2);
    canvas.save();
    // 绘制文字前平移10像素
    canvas.translate(10, 0);

    // 父类完成的方法,即绘制文本
    super.onDraw(canvas);
    canvas.restore();
  }
示例#13
0
 @Override
 protected void onDraw(Canvas canvas) {
   // TODO Auto-generated method stub
   super.onDraw(canvas);
   Paint paint = new Paint();
   paint.setStyle(Paint.Style.STROKE);
   paint.setColor(getTextColors().getDefaultColor());
   Path path = new Path();
   path.moveTo(0, getHeight() / 2);
   path.lineTo(getWidth(), getHeight() / 2);
   PathEffect effects = new DashPathEffect(new float[] {5, 5, 5, 5}, 1);
   paint.setPathEffect(effects);
   canvas.drawPath(path, paint);
 }
  @TargetApi(Build.VERSION_CODES.LOLLIPOP)
  @Override
  protected void onDraw(Canvas canvas) {

    int center = getWidth() / 2;
    int radius = getWidth() / 4;

    initPaint();
    drawBackground(center, radius, canvas);
    drawProgress(center, radius, canvas);

    setTextColor(progressbarColor);
    setGravity(Gravity.CENTER);
    super.onDraw(canvas);
  }
  @Override
  protected void onDraw(Canvas canvas) {
    if (useDefault) {
      super.onDraw(canvas);
      return;
    }

    int width;

    Object ob;

    int leftPadding = getCompoundPaddingLeft();
    int topPadding = getCompoundPaddingTop();

    float height = 0 + topPadding + lineSpacing;
    // 只有一行时
    if (oneLineWidth != -1) {
      height = getMeasuredHeight() / 2 - contentList.get(0).height / 2;
    }

    for (int i = 0; i < contentList.size(); i++) {
      // 绘制一行
      float realDrawedWidth = 0 + leftPadding;
      LINE line = contentList.get(i);
      for (int j = 0; j < line.line.size(); j++) {
        ob = line.line.get(j);
        width = line.widthList.get(j);

        if (ob instanceof String) {
          canvas.drawText((String) ob, realDrawedWidth, height + line.height, paint);
          realDrawedWidth += width;
        } else if (ob instanceof ImageSpan) {
          ImageSpan is = (ImageSpan) ob;
          Drawable d = is.getDrawable();

          int left = (int) (realDrawedWidth);
          int top = (int) height;
          int right = (int) (realDrawedWidth + width);
          int bottom = (int) (height + line.height);
          d.setBounds(left, top, right, bottom);
          d.draw(canvas);
          realDrawedWidth += width;
        }
      }
      height += line.height + lineSpacing;
    }
  }
示例#16
0
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   // ʵÀý»¯Ò»Ö§»­±Ê
   Paint paint = new Paint();
   // ÉèÖÃËù»æÖƵı߿òÑÕɫΪºÚÉ«
   paint.setColor(android.graphics.Color.BLACK);
   // »æÖÆÉϱ߿ò
   // canvas.drawLine(0, 0, this.getWidth() - 1, 0, paint);
   // »æÖÆ×ó±ß¿ò
   // canvas.drawLine(0, 0, 0, this.getHeight() - 1, paint);
   // »æÖÆÓұ߿ò
   // canvas.drawLine(this.getWidth() - 1, 0, this.getWidth() - 1,
   // this.getHeight() - 1, paint);
   // »æÖÆϱ߿ò
   canvas.drawLine(0, this.getHeight() - 1, this.getWidth() - 1, this.getHeight() - 1, paint);
 }
  protected void onDraw(Canvas canvas) {
    if (mCache != null) {
      if (mUpdateCachedBitmap) {
        int l = getMeasuredWidth();
        int k = getMeasuredHeight();
        String s = getText().toString();
        Rect rect = new Rect();
        android.text.TextPaint textpaint = getPaint();
        int i1 = (int) textpaint.measureText(s);
        textpaint.getTextBounds("x", 0, 1, rect);
        mCanvas.setBitmap(mCache);
        mCanvas.drawColor(0, android.graphics.PorterDuff.Mode.CLEAR);
        int j1 = getPaddingLeft();
        int k1 = getPaddingTop();
        Drawable adrawable[] = getCompoundDrawables();
        for (int i = 0; i < adrawable.length; i++) {
          if (adrawable[i] != null) {
            adrawable[i].setBounds(
                j1,
                k1,
                adrawable[i].getIntrinsicWidth() + j1,
                adrawable[i].getIntrinsicHeight() + k1);
            adrawable[i].draw(mCanvas);
          }
        }

        int j = l - getPaddingRight() - i1;
        k = (rect.height() + k) / 2;
        mPaint.setStrokeWidth(mStrokeWidth);
        mPaint.setColor(mStrokeColor);
        mPaint.setTextSize(getTextSize());
        mCanvas.drawText(s, j, k, mPaint);
        mPaint.setStrokeWidth(0.0F);
        mPaint.setColor(mTextColor);
        mCanvas.drawText(s, j, k, mPaint);
        mUpdateCachedBitmap = false;
      }
      canvas.drawBitmap(mCache, 0.0F, 0.0F, mPaint);
      return;
    } else {
      super.onDraw(canvas);
      return;
    }
  }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    int red = (int) (mTextOriginColorR * mProgress);
    int green = (int) (mTextOriginColorG * mProgress);
    int blue = (int) (mTextOriginColorB * mProgress);

    //		mPaint.setColor(color);
    mPaint.setARGB(255, red, green, blue);
    canvas.save(Canvas.CLIP_SAVE_FLAG);

    int size = mTextNormalSize;
    //		Log.e("", "bSelected="+bSelected);
    if (isFirst) {
      isFirst = false;
      if (bSelected) {
        size = mTextSelectSize;

      } else {
        size = mTextNormalSize;
      }
    } else {
      size = (int) (mTextNormalSize + (mTextSelectSize - mTextNormalSize) * mProgress);
    }
    mPaint.setTextSize(size);

    canvas.drawText(mText, mTextStartX, getMeasuredHeight() / 2 + mTextBound.height() / 2, mPaint);
    canvas.restore();

    //		if(mDirection == DIRECTION_LEFT)
    //		{
    //			drawChangeLeft(canvas, r);
    //			drawOriginLeft(canvas, r);
    //		}else
    //		{
    //			 drawOriginRight(canvas, r);
    //			 drawChangeRight(canvas, r);
    //		}

  }
  @Override
  protected void onDraw(Canvas canvas) {
    Paint paint = new Paint();
    mRadius = Math.min(getHeight(), getWidth()) / 2;

    if (ctType == 1) {
      setBackgroundCompat(getWidth(), getHeight());
    } else if (ctType == 2) {
      paint.setColor(borderColor);
      paint.setAntiAlias(true);
      paint.setAlpha((int) (255 * borderAlpha));
      canvas.drawCircle(getWidth() / 2, getHeight() / 2, mRadius, paint);
    } else {
      borderWidth = 0;
    }

    paint.setColor(backgroundColor);
    paint.setAntiAlias(true);
    canvas.drawCircle(getWidth() / 2, getHeight() / 2, mRadius - borderWidth, paint);

    super.onDraw(canvas);
  }
 @Override
 protected void onDraw(Canvas canvas) {
   switch (mStatus) {
     case INIT:
       drawLine(canvas, 90, 180, 0);
       drawButton(canvas);
       break;
     case RIPPLE:
       drawRipple(canvas);
       drawLine(canvas, 90, 180, 0);
       drawButton(canvas);
       break;
     case LINE_MOVE:
       drawLine(canvas, 90, mSweepAng, mLinePosX);
       drawButton(canvas);
       break;
     case TICK:
       drawButton(canvas);
       drawTick(canvas);
       break;
   }
   super.onDraw(canvas);
 }
示例#21
0
  @SuppressLint("NewApi")
  @Override
  protected void onDraw(Canvas canvas) {
    // If wrap is disabled then,
    // request original onDraw
    if (!wrapEnabled) {
      super.onDraw(canvas);
      return;
    }

    // Active canas needs to be set
    // based on cacheEnabled
    Canvas activeCanvas = null;

    // Set the active canvas based on
    // whether cache is enabled
    if (cacheEnabled) {

      if (cache != null) {
        // Draw to the OS provided canvas
        // if the cache is not empty
        canvas.drawBitmap(cache, 0, 0, paint);
        return;
      } else {
        // Create a bitmap and set the activeCanvas
        // to the one derived from the bitmap
        cache = Bitmap.createBitmap(getWidth(), getHeight(), Config.ARGB_4444);
        activeCanvas = new Canvas(cache);
      }
    } else {
      // Active canvas is the OS
      // provided canvas
      activeCanvas = canvas;
    }

    // Pull widget properties
    paint.setColor(getCurrentTextColor());
    paint.setTypeface(getTypeface());
    paint.setTextSize(getTextSize());
    paint.setTextAlign(_align);
    paint.setFlags(Paint.ANTI_ALIAS_FLAG);

    // minus out the paddings pixel
    dirtyRegionWidth = getWidth() - getPaddingLeft() - getPaddingRight();
    int maxLines = Integer.MAX_VALUE;
    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
      maxLines = getMaxLines();
    }
    int lines = 1;
    blocks = getText().toString().split("((?<=\n)|(?=\n))");
    verticalOffset = horizontalFontOffset = getLineHeight() - 0.5f; // Temp fix
    spaceOffset = paint.measureText(" ");

    for (int i = 0; i < blocks.length && lines <= maxLines; i++) {
      block = blocks[i];
      horizontalOffset = 0;

      if (block.length() == 0) {
        continue;
      } else if (block.equals("\n")) {
        verticalOffset += horizontalFontOffset;
        continue;
      }

      block = block.trim();

      if (block.length() == 0) {
        continue;
      }

      wrappedObj = TextJustifyUtils.createWrappedLine(block, paint, spaceOffset, dirtyRegionWidth);

      wrappedLine = ((String) wrappedObj[0]);
      wrappedEdgeSpace = (Float) wrappedObj[1];
      lineAsWords = wrappedLine.split(" ");
      strecthOffset =
          wrappedEdgeSpace != Float.MIN_VALUE ? wrappedEdgeSpace / (lineAsWords.length - 1) : 0;

      for (int j = 0; j < lineAsWords.length; j++) {
        String word = lineAsWords[j];
        if (lines == maxLines && j == lineAsWords.length - 1) {
          activeCanvas.drawText("...", horizontalOffset, verticalOffset, paint);

        } else if (j == 0) {
          // if it is the first word of the line, text will be drawn starting from right edge of
          // textview
          if (_align == Align.RIGHT) {
            activeCanvas.drawText(word, getWidth() - (getPaddingRight()), verticalOffset, paint);
            // add in the paddings to the horizontalOffset
            horizontalOffset += getWidth() - (getPaddingRight());
          } else {
            activeCanvas.drawText(word, getPaddingLeft(), verticalOffset, paint);
            horizontalOffset += getPaddingLeft();
          }

        } else {
          activeCanvas.drawText(word, horizontalOffset, verticalOffset, paint);
        }
        if (_align == Align.RIGHT)
          horizontalOffset -= paint.measureText(word) + spaceOffset + strecthOffset;
        else horizontalOffset += paint.measureText(word) + spaceOffset + strecthOffset;
      }

      lines++;

      if (blocks[i].length() > 0) {
        blocks[i] = blocks[i].substring(wrappedLine.length());
        verticalOffset += blocks[i].length() > 0 ? horizontalFontOffset : 0;
        i--;
      }
    }

    if (cacheEnabled) {
      // Draw the cache onto the OS provided
      // canvas.
      canvas.drawBitmap(cache, 0, 0, paint);
    }
  }
示例#22
0
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   //		Log.e(TAG, "onDraw:width = " + this.getWidth());
   canvas.drawLine(startX, this.getHeight(), startX + width, this.getHeight(), paint);
 }
示例#23
0
  @Override
  public void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    freeze();
    Drawable restoreBackground = this.getBackground();
    Drawable[] restoreDrawables = this.getCompoundDrawables();
    int restoreColor = this.getCurrentTextColor();

    this.setCompoundDrawables(null, null, null, null);

    for (Shadow shadow : outerShadows) {
      this.setShadowLayer(shadow.r, shadow.dx, shadow.dy, shadow.color);
      super.onDraw(canvas);
    }
    this.setShadowLayer(0, 0, 0, 0);
    this.setTextColor(restoreColor);

    if (this.foregroundDrawable != null && this.foregroundDrawable instanceof BitmapDrawable) {
      generateTempCanvas();
      super.onDraw(tempCanvas);
      Paint paint = ((BitmapDrawable) this.foregroundDrawable).getPaint();
      paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
      this.foregroundDrawable.setBounds(canvas.getClipBounds());
      this.foregroundDrawable.draw(tempCanvas);
      canvas.drawBitmap(tempBitmap, 0, 0, null);
      tempCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
    }

    if (strokeColor != null) {
      TextPaint paint = this.getPaint();
      paint.setStyle(Style.STROKE);
      paint.setStrokeJoin(strokeJoin);
      paint.setStrokeMiter(strokeMiter);
      this.setTextColor(strokeColor);
      paint.setStrokeWidth(strokeWidth);
      super.onDraw(canvas);
      paint.setStyle(Style.FILL);
      this.setTextColor(restoreColor);
    }
    if (innerShadows.size() > 0) {
      generateTempCanvas();
      TextPaint paint = this.getPaint();
      for (Shadow shadow : innerShadows) {
        this.setTextColor(shadow.color);
        super.onDraw(tempCanvas);
        this.setTextColor(0xFF000000);
        paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
        paint.setMaskFilter(new BlurMaskFilter(shadow.r, BlurMaskFilter.Blur.NORMAL));

        tempCanvas.save();
        tempCanvas.translate(shadow.dx, shadow.dy);
        super.onDraw(tempCanvas);
        tempCanvas.restore();
        canvas.drawBitmap(tempBitmap, 0, 0, null);
        tempCanvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);

        paint.setXfermode(null);
        paint.setMaskFilter(null);
        this.setTextColor(restoreColor);
        this.setShadowLayer(0, 0, 0, 0);
      }
    }

    if (restoreDrawables != null) {
      this.setCompoundDrawablesWithIntrinsicBounds(
          restoreDrawables[0], restoreDrawables[1], restoreDrawables[2], restoreDrawables[3]);
    }
    this.setBackgroundDrawable(restoreBackground);
    this.setTextColor(restoreColor);

    unfreeze();
  }
  /*
   * (non-Javadoc)
   *
   * @see android.view.View#onDraw(android.graphics.Canvas)
   */
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // Calculate views bounds
    ArrayList<Rect> bounds = calculateAllBounds(paintText);

    // If no value then add a fake one
    int count =
        (viewFlow != null && viewFlow.getAdapter() != null) ? viewFlow.getAdapter().getCount() : 1;

    // Verify if the current view must be clipped to the screen
    Rect curViewBound = bounds.get(currentPosition);
    int curViewWidth = curViewBound.right - curViewBound.left;
    if (curViewBound.left < 0) {
      // Try to clip to the screen (left side)
      clipViewOnTheLeft(curViewBound, curViewWidth);
    }
    if (curViewBound.right > getLeft() + getWidth()) {
      // Try to clip to the screen (right side)
      clipViewOnTheRight(curViewBound, curViewWidth);
    }

    // Left views starting from the current position
    if (currentPosition > 0) {
      for (int iLoop = currentPosition - 1; iLoop >= 0; iLoop--) {
        Rect bound = bounds.get(iLoop);
        int w = bound.right - bound.left;
        // Si left side is outside the screen
        if (bound.left < 0) {
          // Try to clip to the screen (left side)
          clipViewOnTheLeft(bound, w);
          // Except if there's an intersection with the right view
          if (iLoop < count - 1 && currentPosition != iLoop) {
            Rect rightBound = bounds.get(iLoop + 1);
            // Intersection
            if (bound.right + TITLE_PADDING > rightBound.left) {
              bound.left = rightBound.left - (w + (int) titlePadding);
            }
          }
        }
      }
    }
    // Right views starting from the current position
    if (currentPosition < count - 1) {
      for (int iLoop = currentPosition + 1; iLoop < count; iLoop++) {
        Rect bound = bounds.get(iLoop);
        int w = bound.right - bound.left;
        // If right side is outside the screen
        if (bound.right > getLeft() + getWidth()) {
          // Try to clip to the screen (right side)
          clipViewOnTheRight(bound, w);
          // Except if there's an intersection with the left view
          if (iLoop > 0 && currentPosition != iLoop) {
            Rect leftBound = bounds.get(iLoop - 1);
            // Intersection
            if (bound.left - TITLE_PADDING < leftBound.right) {
              bound.left = leftBound.right + (int) titlePadding;
            }
          }
        }
      }
    }

    // Now draw views
    for (int iLoop = 0; iLoop < count; iLoop++) {
      // Get the title
      String title = getTitle(iLoop);
      Rect bound = bounds.get(iLoop);
      // Only if one side is visible
      if ((bound.left > getLeft() && bound.left < getLeft() + getWidth())
          || (bound.right > getLeft() && bound.right < getLeft() + getWidth())) {
        Paint paint = paintText;
        // Change the color is the title is closed to the center
        int middle = (bound.left + bound.right) / 2;
        if (Math.abs(middle - (getWidth() / 2)) < 20) {
          paint = paintSelected;
        }
        canvas.drawText(title, bound.left, bound.bottom, paint);
      }
    }

    // Draw the footer line
    path = new Path();
    path.moveTo(0, getHeight() - footerLineHeight);
    path.lineTo(getWidth(), getHeight() - footerLineHeight);
    path.close();
    canvas.drawPath(path, paintFooterLine);
    // Draw the footer triangle
    path = new Path();
    path.moveTo(getWidth() / 2, getHeight() - footerLineHeight - footerTriangleHeight);
    path.lineTo(getWidth() / 2 + footerTriangleHeight, getHeight() - footerLineHeight);
    path.lineTo(getWidth() / 2 - footerTriangleHeight, getHeight() - footerLineHeight);
    path.close();
    canvas.drawPath(path, paintFooterTriangle);
  }
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   canvas.drawRect(0, 0, getWidth(), getHeight(), paint);
 }
示例#26
0
 public void onDraw(Canvas c) {
   Log.d(TAG, "asked to draw hunk");
   updateDiffTextStateIfRequired();
   super.onDraw(c);
 }
示例#27
0
 @Override
 protected void onDraw(Canvas canvas) {
   canvas.drawRoundRect(mRect, mRadius, mRadius, mBackgroundPaint);
   super.onDraw(canvas);
 }
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
 }