fresco实现圆角、圆形头像
来源:互联网 发布:淘宝关键词搜索人气 编辑:程序博客网 时间:2024/06/04 00:31
http://blog.csdn.net/aotian16/article/details/53334489
效果图
代码
需要注意的地方用注释给出。
可以在github上下载源码。点我试试。
Uri uri = Uri.parse("https://pic4.zhimg.com/03b2d57be62b30f158f48f388c8f3f33_b.png"); SimpleDraweeView commonImageView = (SimpleDraweeView) findViewById(R.id.commonImageView); commonImageView.setImageURI(uri); SimpleDraweeView circleImageView = (SimpleDraweeView) findViewById(R.id.circleImageView); circleImageView.setImageURI(uri); SimpleDraweeView roundedImageView = (SimpleDraweeView) findViewById(R.id.roundedImageView); roundedImageView.setImageURI(uri);
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="center" android:text="common image" /> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/commonImageView" android:layout_width="130dp" android:layout_height="130dp" fresco:actualImageScaleType="centerCrop" fresco:placeholderImage="@mipmap/ic_launcher" fresco:placeholderImageScaleType="centerCrop" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="center" android:text="circle image" /> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/circleImageView" android:layout_width="130dp" android:layout_height="130dp" fresco:actualImageScaleType="centerCrop" fresco:placeholderImage="@mipmap/ic_launcher" fresco:placeholderImageScaleType="centerCrop" fresco:roundAsCircle="true" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="100dp" android:layout_height="wrap_content" android:layout_gravity="center" android:text="rounded image" /> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/roundedImageView" android:layout_width="130dp" android:layout_height="130dp" fresco:actualImageScaleType="centerCrop" fresco:placeholderImage="@mipmap/ic_launcher" fresco:placeholderImageScaleType="centerCrop" fresco:roundedCornerRadius="25dp" /> </LinearLayout> </LinearLayout>
0 0