android中用Fresco实现圆角图片和圆形图片
2017-12-21 10:44
429 查看
效果图
代码
需要注意的地方用注释给出。可以在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);1
2
3
4
5
6
7
8
9
<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>
相关文章推荐
- Android图片加载神器之Fresco-圆形圆角二合一教程[Java代码实现圆形圆角效果]
- Android图片加载神器之Fresco-圆形圆角二合一[Java代码实现圆形圆角效果]
- Android图片加载神器之Fresco-圆形圆角二合一教程[Java代码实现圆形圆角效果]
- Android图片加载神器之Fresco-圆形圆角二合一教程[Java代码实现圆形圆角效果]
- Android图片加载神器之Fresco-Java代码实现圆形圆角效果
- android中用Fresco实现圆角图片和圆形图片
- Android图片加载神器之Fresco-圆形圆角二合一教程[Java代码实现圆形圆角效果]
- Android图片加载神器之Fresco-圆形圆角二合一[Java代码实现圆形圆角效果]
- Android 完美实现图片圆角和圆形
- Android Xfermode 实战 实现圆形、圆角图片
- Android 完美实现图片圆角和圆形(对实现进行分析)
- Android 完美实现图片圆角和圆形(对实现进行分析)
- Android 自定义View修炼-Android实现圆形、圆角和椭圆自定义图片View(使用BitmapShader图形渲染方法)
- Android ImageView实现圆角,圆形图片
- Android之圆形(圆角)图片的实现(一)
- Android 完美实现图片圆角和圆形(对实现进行分析)
- Android Xfermode 实战 实现圆形、圆角图片
- Android Xfermode 实战 实现圆形、圆角图片
- Android BitmapShader 实战 实现圆形、圆角图片
- Android Xfermode 实战 实现圆形、圆角图片