美文网首页
Android圆角图片的两种实现

Android圆角图片的两种实现

作者: 活着工作室 | 来源:发表于2017-04-18 15:28 被阅读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);​

相关文章

网友评论

      本文标题:Android圆角图片的两种实现

      本文链接:https://www.haomeiwen.com/subject/vhnfzttx.html