在Android开发,图片是很常用的,用户头像基本上都是圆形的,我们可以自己写画布类,将其变为圆形的,但是比较麻烦获取bitmap体验也不好,在这里使用开源框架roundedimageview。
1.首先在build.gradle中添加:
compile 'com.makeramen:roundedimageview:2.3.0'
2.在布局中:
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/xquserimage"
app:riv_oval="true"
android:layout_gravity="center"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/weidenglu"/>
3.其余使用与imageview类似。