Android圆角图片的两种实现

2017-04-18  本文已影响0人  活着工作室

//第一种

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

上一篇下一篇

猜你喜欢

热点阅读