工作中 我们常常遇到需求就是把图片转换为圆形,至于为什么,可能是ui的审美吧,不太懂为啥。 既然有这个要求了,行,那 just do it。
最简单的方法,github 啊,目前项目中用的的是
compile 'de.hdodenhof:circleimageview:2.1.0'
//(支持边框,颜色设置等……)
[github地址] (https://github.com/hdodenhof/CircleImageView)
使用方法非常简单
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="@drawable/profile"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"/>
java中 用法跟ImageView一样。OK,就是这么简单。小伙伴们 快点用起来吧。