android Fresco gif图片不显示

2018-03-29 22:24:37

解决问题的方法

我是按照官方文档上写的来实现的代码如下。

SimpleDraweeView view = (SimpleDraweeView) findViewById(id);

Uri uri =  Uri.parse(imgUrl);
DraweeController controller = Fresco.newDraweeControllerBuilder()
        .setUri(uri)
        .setAutoPlayAnimations(true)
        .build();
view.setController(controller);

结果gif图片并没有显示,试了试普通图片并没有问题。那么问题来了,



最后百度搜索,发现高版本的Fresco   需要单独引入,gif模块。官方文档如下。


使用 Android Studio 或者其他 Gradle 构建的项目

编辑 build.gradle 文件:

1
2
3
4
dependencies {
  // 其他依赖
  compile 'com.facebook.fresco:fresco:0.12.0'}

下面的依赖需要根据需求添加:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
dependencies {
  // 在 API < 14 上的机器支持 WebP 时,需要添加
  compile 'com.facebook.fresco:animated-base-support:0.12.0'

  // 支持 GIF 动图,需要添加
  compile 'com.facebook.fresco:animated-gif:0.12.0'

  // 支持 WebP (静态图+动图),需要添加
  compile 'com.facebook.fresco:animated-webp:0.12.0'
  compile 'com.facebook.fresco:webpsupport:0.12.0'

  // 仅支持 WebP 静态图,需要添加
  compile 'com.facebook.fresco:webpsupport:0.12.0'}


  • 2021-05-25 13:10:49

    npm 多个不同版本的依赖

    提起 npm,大家第一个想到的应该就是 npm install 了,但是 npm install 之后生成的 node_modules 大家有观察过吗?package-lock.json 文件的作用大家知道吗?除了 dependencies 和 devDependencies,其他的依赖有什么作用呢?接下来,本文将针对 npm 中的你可能忽略的细节和大家分享一些经验 。