您现在的位置是:首页 > 文章详情

[Android Pro] Android 必知必会-使用 supportV4 的 RoundedBitmapDrawable 实现圆角

日期:2017-05-10点击:439

RoundedBitmapDrawable 是 supportV4 下的一个类,有了它,显示圆角和圆形图片的情况下就不需要额外的第三方类库了,还能和各种图片加载库配合使用。

背景

今天无意间看到一段实现圆形头像的代码:

1
2
RoundedBitmapDrawable drawable = RoundedBitmapDrawableFactory.create(getResources(), bitmap);
drawable.setCircular( true );

RoundedBitmapDrawable 这个类顿时就引起我的好奇了,一查发现是android.support.v4.graphics.drawable.RoundedBitmapDrawable ,点击此处 可以看到官方的介绍。这个类中的两个方法是今天的主角:

return method
void setCircular(boolean circular) : Sets the image shape to circular.
void setCornerRadius(float cornerRadius) : Sets the corner radius to be applied when drawing the bitmap.

setCircular(boolean circular) : 把图片的形状设为圆形;

setCornerRadius(float cornerRadius) : 设置图片的圆角半径。

分类:  Android Pro
本文转自demoblog博客园博客,原文链接http://www.cnblogs.com/0616--ataozhijia/p/6397727.html如需转载请自行联系原作者

demoblog
原文链接:https://yq.aliyun.com/articles/360554
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章