反应原生的GIF图像在android中不起作用

时间:2018-05-25 06:58:30

标签: android react-native

动画在Android

中的gif图像中无效

Android gif image without animation

3 个答案:

答案 0 :(得分:8)

  

对于本机版本> = 0.60:

implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'

答案 1 :(得分:4)

更新:react-native@0.57.0

// For animated GIF support
// ./android/app/build.gradle

implementation 'com.facebook.fresco:fresco:1.10.0'
implementation 'com.facebook.fresco:animated-gif:1.10.0'

答案 2 :(得分:2)

请按照FB docs中的详细说明,它会指定您需要的所需内容。

您需要在android / app / build.gradle中添加一些可选模块,具体取决于您的应用程序的需求。

dependencies {
  // If your app supports Android versions before Ice Cream Sandwich (API level 14)
  compile 'com.facebook.fresco:animated-base-support:1.3.0'

  // For animated GIF support
  compile 'com.facebook.fresco:animated-gif:1.3.0'

  // For WebP support, including animated WebP
  compile 'com.facebook.fresco:animated-webp:1.3.0'
  compile 'com.facebook.fresco:webpsupport:1.3.0'

  // For WebP support, without animations
  compile 'com.facebook.fresco:webpsupport:1.3.0'
}

此外,如果您将GIF与ProGuard一起使用,则需要在proguard-rules.pro中添加此规则:

-keep class com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl {
  public AnimatedFactoryImpl(com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory, com.facebook.imagepipeline.core.ExecutorSupplier);
}