所需依赖
implementation 'com.facebook.fresco:fresco:0.12.0'
//其他依赖
// 在 API < 14 上的机器支持 WebP 时,需要添加
implementation 'com.facebook.fresco:animated-base-support:0.12.0'
// 支持 GIF 动图,需要添加
implementation 'com.facebook.fresco:animated-gif:0.12.0'
// 支持 WebP (静态图+动图),需要添加
implementation 'com.facebook.fresco:animated-webp:0.12.0'
implementation 'com.facebook.fresco:webpsupport:0.12.0'
// 仅支持 WebP 静态图,需要添加
//implementation 'com.facebook.fresco:webpsupport:0.12.0'
implementation 'com.android.support:support-v4:27.1.1'
Uri uri = Uri.parse("https://ws1.sinaimg.cn/large/0065oQSqly1fuo54a6p0uj30sg0zdqnf.jpg");
image_view.setAspectRatio(1.33f);
//设置圆角的效果
RoundingParams roundingParams = RoundingParams.fromCornersRadius(20f);
//设置圆圈的效果
roundingParams.setRoundAsCircle(true);
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
GenericDraweeHierarchy build = builder
.setRoundingParams(roundingParams)
.build();
image_view.setHierarchy(build);
image_view.setImageURI(uri);
PipelineDraweeControllerBuilder controllerBuilder = Fresco.newDraweeControllerBuilder();
AbstractDraweeController build = controllerBuilder
.setUri("http://img.zcool.cn/community/012b275930ff3ba8012193a349e497.gif")
.setAutoPlayAnimations(true)
.build();
GenericDraweeHierarchyBuilder builder = new GenericDraweeHierarchyBuilder(getResources());
GenericDraweeHierarchy build1 = builder
.build();
image_view.setController(build);
String gifurlString = "http://img.zcool.cn/community/012b275930ff3ba8012193a349e497.gif";
final String requestUrlString = "https://ws1.sinaimg.cn/large/0065oQSqly1fuo54a6p0uj30sg0zdqnf.jpg";
Uri gifUri = Uri.parse(requestUrlString);
Uri requestUri = Uri.parse(requestUrlString)
Uri uri = requestUri;