Android圆角图片的两种实现

//第一种

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);​

你可能感兴趣的:(Android圆角图片的两种实现)