我在为自定义imageView制作圆角时遇到了问题。这是我的代码片段和显示我的问题的图像
原始图片
错误的图纸
我的代码:
@Override
protected void onDraw(Canvas canvas) {
if (mCurrentBitmapDrawable != null) {
if (mTopLeft == 0 && mTopRight == 0 && mBottomLeft == 0 && mBottomRight == 0) {
Log.d("CustomImageView-def", "mTopLeft = " + String.valueOf(mTopLeft));
super.onDraw(canvas);
return;
}
Log.d("CustomImageView-cust", "mTopLeft = " + String.valueOf(mTopLeft));
mBitmapShader = new BitmapShader(mCurrentBitmapDrawable.getBitmap(), Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
paint.setAntiAlias(true);
paint.setShader(mBitmapShader);
mRoundRectShape.resize(getWidth(), getHeight());
mRoundRectShape.draw(canvas, paint);
}
}