[英]Gif image is not working in android in react native
Animation 在 android 中的 gif 图像中不起作用
对于反应本机版本>=0.60:
在构建自己的原生代码时,Android 上默认不支持 GIF 和 WebP。
您需要在android/app/build.gradle
添加一些可选模块,具体取决于您的应用程序的需要。
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
更新: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'
请遵循FB 文档中的详细信息,它将指定您需要的所需内容。
您需要在 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);
}
对于 React Native 版本:0.66.4
在 android/app/build.gradle 文件中添加以下几行,
implementation 'com.facebook.fresco:fresco:2.0.0'
// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.6.0'
// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:2.0.0'
implementation 'com.facebook.fresco:webpsupport:2.0.0'
并像这样使用它:
<Image
source={require('../assets/splah.gif')}
style={{ width: '100%',height:'100%' }}
/>
在 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'
}
我已经通过在 android/app/build.gradle 中执行此操作解决了我的问题
实施 'com.facebook.fresco:animated-gif:2.6.0'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.