本文整理了Java中android.widget.ImageView.onDraw()
方法的一些代码示例,展示了ImageView.onDraw()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.onDraw()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:onDraw
暂无
代码示例来源:origin: hdodenhof/CircleImageView
@Override
protected void onDraw(Canvas canvas) {
if (mDisableCircularTransformation) {
super.onDraw(canvas);
return;
}
if (mBitmap == null) {
return;
}
if (mCircleBackgroundColor != Color.TRANSPARENT) {
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);
}
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
if (mBorderWidth > 0) {
canvas.drawCircle(mBorderRect.centerX(), mBorderRect.centerY(), mBorderRadius, mBorderPaint);
}
}
代码示例来源:origin: qiujuer/Genius-Android
@Override
protected synchronized void onDraw(Canvas canvas) {
final TouchEffectDrawable d = mTouchDrawable;
if (d != null) {
d.draw(canvas);
}
super.onDraw(canvas);
}
代码示例来源:origin: qiujuer/Genius-Android
@Override
protected synchronized void onDraw(Canvas canvas) {
super.onDraw(canvas);
// draw the effect on the image
final TouchEffectDrawable d = mTouchDrawable;
if (d != null) {
d.draw(canvas);
}
}
代码示例来源:origin: lygttpod/SuperTextView
@Override
protected void onDraw(Canvas canvas) {
if (mDisableCircularTransformation) {
super.onDraw(canvas);
return;
}
if (mBitmap == null) {
return;
}
if (mCircleBackgroundColor != Color.TRANSPARENT) {
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);
}
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
if (mBorderWidth > 0) {
canvas.drawCircle(mBorderRect.centerX(), mBorderRect.centerY(), mBorderRadius, mBorderPaint);
}
}
代码示例来源:origin: Aspsine/SwipeToLoadLayout
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mIfDrawText) {
String text = String.format("%s%%", mProgress);
int x = getWidth() / 2 - text.length() * mTextSize / 4;
int y = getHeight() / 2 + mTextSize / 4;
canvas.drawText(text, x, y, mTextPaint);
}
}
代码示例来源:origin: alexvasilkov/GestureViews
@Override
protected void onDraw(Canvas canvas) {
init();
if (bitmapPaint.getShader() == null) {
super.onDraw(canvas);
} else {
float rx = 0.5f * rect.width();
float ry = 0.5f * rect.height();
canvas.drawRoundRect(rect, rx, ry, bitmapPaint);
}
}
代码示例来源:origin: android-cjj/Android-MaterialRefreshLayout
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mIfDrawText) {
String text = String.format("%s%%", mProgress);
int x = getWidth() / 2 - text.length() * mTextSize / 4;
int y = getHeight() / 2 + mTextSize / 4;
canvas.drawText(text, x, y, mTextPaint);
}
}
代码示例来源:origin: GitLqr/LQRWeChat
protected void onDraw(Canvas canvas) {
canvas.rotate(rotation, getWidth() / 2, getHeight() / 2);
super.onDraw(canvas);
}
代码示例来源:origin: sephiroth74/ImageViewZoom
@Override
protected void onDraw(final Canvas canvas) {
if (getScaleType() == ScaleType.FIT_XY) {
final Drawable drawable = getDrawable();
if (null != drawable) {
drawable.draw(canvas);
}
} else {
super.onDraw(canvas);
}
}
}
代码示例来源:origin: jaydenxiao2016/AndroidFire
protected void onDraw(Canvas canvas) {
canvas.rotate(rotation, getWidth() / 2, getHeight() / 2);
super.onDraw(canvas);
}
代码示例来源:origin: siyamed/android-shape-imageview
@Override
public void onDraw(Canvas canvas) {
if(DEBUG) {
canvas.drawRGB(10, 200, 200);
}
if(!getPathHelper().onDraw(canvas)) {
super.onDraw(canvas);
}
}
代码示例来源:origin: wangdan/AisenWeiBo
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (getWidth() > 0 && getHeight() > 0) {
canvas.drawBitmap(bitmapPlay, (getWidth() - bitmapPlay.getWidth()) / 2, (getHeight() - bitmapPlay.getHeight()) / 2, paint);
}
}
代码示例来源:origin: gjiazhe/PanoramaImageView
@Override
protected void onDraw(Canvas canvas) {
if (!mEnablePanoramaMode || getDrawable() == null || isInEditMode()) {
super.onDraw(canvas);
return;
canvas.save();
canvas.translate(currentOffsetX, 0);
super.onDraw(canvas);
canvas.restore();
} else if (mOrientation == ORIENTATION_VERTICAL) {
canvas.save();
canvas.translate(0, currentOffsetY);
super.onDraw(canvas);
canvas.restore();
代码示例来源:origin: jeasonlzy/NineGridView
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (moreNum > 0) {
canvas.drawColor(maskColor);
float baseY = getHeight() / 2 - (textPaint.ascent() + textPaint.descent()) / 2;
canvas.drawText(msg, getWidth() / 2, baseY, textPaint);
}
}
代码示例来源:origin: CameraKit/blurkit-android
@Override
protected void onDraw(Canvas canvas) {
Drawable myDrawable = getDrawable();
if (myDrawable!=null && myDrawable instanceof BitmapDrawable && mCornerRadius > 0) {
rectF.set(myDrawable.getBounds());
int prevCount = canvas.saveLayer(rectF, null, Canvas.ALL_SAVE_FLAG);
getImageMatrix().mapRect(rectF);
Paint paint = ((BitmapDrawable) myDrawable).getPaint();
paint.setAntiAlias(true);
paint.setColor(DEFAULT_COLOR);
Xfermode prevMode = paint.getXfermode();
canvas.drawARGB(DEFAULT_RGB, DEFAULT_RGB, DEFAULT_RGB, DEFAULT_RGB);
canvas.drawRoundRect(rectF, mCornerRadius, mCornerRadius, paint);
paint.setXfermode(porterDuffXfermode);
super.onDraw(canvas);
paint.setXfermode(prevMode);
canvas.restoreToCount(prevCount);
} else {
super.onDraw(canvas);
}
}
代码示例来源:origin: lyft/scissors
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (bitmap == null) {
return;
}
drawBitmap(canvas);
if (shape == Shape.RECTANGLE) {
drawSquareOverlay(canvas);
} else {
drawOvalOverlay(canvas);
}
}
代码示例来源:origin: code-mc/material-icon-lib
@Override
protected void onDraw(Canvas canvas) {
if (getWidth() == 0 || getHeight() == 0) return;
int scaledWidth = getMeasuredWidth();
int scaledHeight = getMeasuredHeight();
int scaleddimen = (mOverruledSize >= 0) ? mOverruledSize : Math.min(scaledHeight, scaledWidth);
boolean redraw = false;
if(mDrawable == null){
redraw = true;
}else{
int initialdimen = Math.min(mDrawable.getIntrinsicHeight(), mDrawable.getIntrinsicHeight());
if(initialdimen != scaleddimen){
redraw = true;
}
}
if(redraw){
if(mOverruledSize >= 0){
mBuilder.setSizePx(mOverruledSize);
}else{
mBuilder.setSizePx(scaleddimen);
}
regenerateDrawable();
}
super.onDraw(canvas);
}
代码示例来源:origin: siyamed/android-shape-imageview
super.onDraw(canvas);
代码示例来源:origin: wangdan/AisenWeiBo
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
代码示例来源:origin: DaxiaK/MyDiary
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.getClipBounds(rect);
rect.bottom--;
rect.right--;
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(3);
canvas.drawRect(rect, paint);
}
}
内容来源于网络,如有侵权,请联系作者删除!