wko*_*tre 12
更新: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'
Run Code Online (Sandbox Code Playgroud)
对于本机版本> = 0.60:
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
Run Code Online (Sandbox Code Playgroud)
请遵循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'
}
Run Code Online (Sandbox Code Playgroud)
此外,如果您将 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);
}
Run Code Online (Sandbox Code Playgroud)
小智 6
对于 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'
Run Code Online (Sandbox Code Playgroud)
并像这样使用它:
<Image
source={require('../assets/splah.gif')}
style={{ width: '100%',height:'100%' }}
/>
Run Code Online (Sandbox Code Playgroud)
React Native 版本更新:0.73
据我了解,RN 0.73 使用 fresco 3.1,所以我必须像这样更改./android/app/build.gradle中的版本
// For animated GIF support
implementation ("com.facebook.fresco:animated-gif:3.1.0")
Run Code Online (Sandbox Code Playgroud)
这对我有用
| 归档时间: |
|
| 查看次数: |
3681 次 |
| 最近记录: |