Skip to content

Commit 7163ea3

Browse files
committed
Draw circle background and border even if no bitmap is set
1 parent b33f76d commit 7163ea3

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

circleimageview/src/main/java/de/hdodenhof/circleimageview/CircleImageView.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,23 +155,23 @@ protected void onDraw(Canvas canvas) {
155155
return;
156156
}
157157

158-
if (mBitmap == null) {
159-
return;
158+
if (mCircleBackgroundColor != Color.TRANSPARENT) {
159+
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);
160160
}
161161

162-
if (mRebuildShader) {
163-
mRebuildShader = false;
162+
if (mBitmap != null) {
163+
if (mRebuildShader) {
164+
mRebuildShader = false;
165+
166+
BitmapShader bitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
167+
bitmapShader.setLocalMatrix(mShaderMatrix);
164168

165-
BitmapShader bitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
166-
bitmapShader.setLocalMatrix(mShaderMatrix);
169+
mBitmapPaint.setShader(bitmapShader);
170+
}
167171

168-
mBitmapPaint.setShader(bitmapShader);
172+
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
169173
}
170174

171-
if (mCircleBackgroundColor != Color.TRANSPARENT) {
172-
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mCircleBackgroundPaint);
173-
}
174-
canvas.drawCircle(mDrawableRect.centerX(), mDrawableRect.centerY(), mDrawableRadius, mBitmapPaint);
175175
if (mBorderWidth > 0) {
176176
canvas.drawCircle(mBorderRect.centerX(), mBorderRect.centerY(), mBorderRadius, mBorderPaint);
177177
}

0 commit comments

Comments
 (0)