//第一种
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.head);
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(),bitmap);
drawable.setCircular(true);
//第二种
Bitmapbitmap = BitmapFactory.decodeResource(getResources(),R.drawable.head);
BitmapShader bitmapShader =newBitmapShader(bitmap,Shader.TileMode.CLAMP,Shader.TileMode.CLAMP);
Paint paint =newPaint();
paint.setShader(bitmapShader);canvas.drawCircle(500,250,200,paint);
canvas.drawCircle(500,250,200,paint);
网友评论