@Override protected void onDraw(Canvas canvas) { //绘制扩散的圆 canvas.drawCircle(centerX, centerY, radius, paint); super.onDraw(canvas); }
@Override protected void onDraw(@NonNull Canvas canvas) { super.onDraw(canvas); if (mPrepareAnimator) { mPrepareAnimator = false; cancelAnimations(); createAnimations(); } if (mAnimator != null) { canvas.drawCircle(mX, mY, mRadius, mPaint); } else { if (mChecked) { canvas.drawColor(mMaskColor); } } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); loaderController.onDraw(canvas, getCompoundPaddingLeft(), getCompoundPaddingTop(), getCompoundPaddingRight(), getCompoundPaddingBottom()); }
@Override protected void onDraw(@NonNull Canvas canvas) { super.onDraw(canvas); mPaint.setStyle(Paint.Style.STROKE); // 空心效果 mPaint.setAntiAlias(true); // 设置画笔为无锯齿 mPaint.setStrokeWidth(strokeWidth); // 线宽 // 设置边框线的颜色, 如果声明为边框跟随文字颜色且当前边框颜色与文字颜色不同时重新设置边框颜色 if (mFollowTextColor && strokeColor != getCurrentTextColor()) strokeColor = getCurrentTextColor(); mPaint.setColor(strokeColor); // 画空心圆角矩形 mRectF.left = mRectF.top = 0.5f * strokeWidth; mRectF.right = getMeasuredWidth() - strokeWidth; mRectF.bottom = getMeasuredHeight() - strokeWidth; canvas.drawRoundRect(mRectF, cornerRadius, cornerRadius, mPaint); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); roundRectShape.onDraw(canvas); } }
@Override protected void onDraw(Canvas canvas) { if(!isLoading) { super.onDraw(canvas); }else{ canvas.drawRect(x,y,x+width,y+height,loadingPaint); canvas.drawRect(rX,rY,rX+rWidth,rY+rHeight,ripplePaint); rX=(rX<width)?rX+5:x-rWidth; post(rippleRunner); } } private Runnable rippleRunner=new Runnable() {
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); Log.d(TAG, "onDraw: " + System.currentTimeMillis()); if (mLinearGradient != null) { mLinearGradient.setLocalMatrix(mShadowMatrix); } }
@Override protected void onDraw(Canvas canvas) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { float c = getWidth() / 2.0f; canvas.drawCircle(c, c, c, paint); } super.onDraw(canvas); } }
@Override protected void onDraw(Canvas canvas) { int w = getWidth(); int h = getHeight(); canvas.clipRect(0, 0, w, h); super.onDraw(canvas); canvas.drawLine(0, h, w, h, mPaint); canvas.drawLine(w, h / 1.8f, w, h, mPaint); canvas.drawLine(0, h / 1.2f, 0, h, mPaint); }
@Override public void onDraw(Canvas canvas) { int width = getWidth(); int height = getHeight(); int radius = Math.min(width, height) / 2; canvas.drawCircle(width / 2, height / 2, radius, mCirclePaint); super.onDraw(canvas); }
@Override protected void onDraw(Canvas canvas) { canvas.rotate(degree, getMeasuredWidth() / 2, getMeasuredHeight() / 2); super.onDraw(canvas); }
@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); }
@Override protected void onDraw(Canvas canvas) { mPaint.setColor(mColor); mPaint.setStyle(Paint.Style.FILL); mPaint.setAntiAlias(true); int r = getMeasuredWidth() > getMeasuredHeight() ? getMeasuredWidth() : getMeasuredHeight(); mRectf.set(getPaddingLeft(), getPaddingTop(), r - getPaddingRight(), r - getPaddingBottom()); canvas.drawArc(mRectf, 0, 360, false, mPaint); super.onDraw(canvas); }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mGradientMatrix != null) { mTranslate += mViewWidth / 5; if (mTranslate > 2 * mViewWidth) { mTranslate = -mViewWidth; } mGradientMatrix.setTranslate(mTranslate, 0); mLinearGradient.setLocalMatrix(mGradientMatrix); postInvalidateDelayed(100); } }
@Override protected void onDraw(Canvas canvas) { float cx = getWidth() / 2.0f; float cy = getHeight() / 2.0f; matrix.reset(); camera.save(); camera.rotateX(angle); camera.getMatrix(matrix); camera.restore(); matrix.postTranslate(cx, cy); matrix.preTranslate(-cx, -cy); canvas.concat(matrix); super.onDraw(canvas); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); translate += DELAY; float textWidth = getPaint().measureText(getText().toString()); if (translate > textWidth + 1 || translate < 1) { DELAY = 0; curRow++; if (curRow > row) { curRow = 0; } } matrix.setTranslate(translate, 0); linearGradient.setLocalMatrix(matrix); postInvalidateDelayed(50); } }
@Override protected void onDraw(Canvas canvas) { Layout layout = getLayout(); bounds.left = layout.getLineLeft(1); bounds.right = layout.getLineRight(1); bounds.top = layout.getLineTop(1); bounds.bottom = layout.getLineBottom(1); canvas.drawRect(bounds, paint); bounds.left = layout.getLineLeft(layout.getLineCount() - 4); bounds.right = layout.getLineRight(layout.getLineCount() - 4); bounds.top = layout.getLineTop(layout.getLineCount() - 4); bounds.bottom = layout.getLineBottom(layout.getLineCount() - 4); canvas.drawRect(bounds, paint); super.onDraw(canvas); } }
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // 把下面的绘制代码移到 super.onDraw() 的上面,就可以让原主体内容盖住你的绘制代码了 // (或者你也可以把 super.onDraw() 移到这段代码的下面) Layout layout = getLayout(); bounds.left = layout.getLineLeft(1); bounds.right = layout.getLineRight(1); bounds.top = layout.getLineTop(1); bounds.bottom = layout.getLineBottom(1); canvas.drawRect(bounds, paint); bounds.left = layout.getLineLeft(layout.getLineCount() - 3); bounds.right = layout.getLineRight(layout.getLineCount() - 3); bounds.top = layout.getLineTop(layout.getLineCount() - 3); bounds.bottom = layout.getLineBottom(layout.getLineCount() - 3); canvas.drawRect(bounds, paint); } }