我有兴趣将半径仅提供给imageview的一个角。我使用以下代码为imageview提供圆角,但它适用于所有四个角,我只想要一个角被舍入。
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);
final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = pixels;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
答案 0 :(得分:-1)
您可以尝试以下方法:
1.扩展ImageView
2.覆盖onDraw方法
一个。创建剪辑路径对象(Path类对象clipPath)
湾定义剪辑区域(clipPath.addArc)
C。将剪辑路径设置为Canvas
d。调用super.Ondraw(Canvas)