您的位置:首页 > 移动开发 > Android开发

android中用Fresco实现圆角图片和圆形图片

2016-11-25 14:58 453 查看

效果图



代码

需要注意的地方用注释给出。

可以在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>


参考文章

fresco-cn圆角和圆圈

原文

android中用RecyclerView实现滑动删除与切换item
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android