我想通过我的 android 反应本机应用程序中的图像标签中的 URL 显示一个简单的 gif,但是当我启动它时,没有显示图像。
中提供的代码docs https://facebook.github.io/react-native/docs/image.html%20docs仅适用于 iOS,不适用于 Android:
<Image
style={styles.gif}
source={{uri: 'http://38.media.tumblr.com/9e9bd08c6e2d10561dd1fb4197df4c4e/tumblr_mfqekpMktw1rn90umo1_500.gif'}}
/>
这里有一个类似的问题,但正如已经说过的,这只适用于 iOS:如何在 React Native 中显示动画 gif? https://stackoverflow.com/questions/35594783/how-do-i-display-an-animated-gif-in-react-native
关于此提交,它应该可以工作:https://github.com/facebook/react-native/commit/fcd7de5301655b39832d49908e5ca72ddaf91f7e https://github.com/facebook/react-native/commit/fcd7de5301655b39832d49908e5ca72ddaf91f7e
我们通过将 GIF 支持等设置为可选,使核心库变得更小。
正因为如此我们必须手动选择 Android 中的 gif 支持 http://frescolib.org/docs/index.html。
将以下两行添加到 android/app/build.gradle 文件的依赖项下:
compile "com.facebook.fresco:animated-gif:1.3.0"
compile "com.facebook.fresco:animated-base-support:1.3.0"
因此,您的依赖项部分可能如下所示:
dependencies {
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile "com.facebook.fresco:animated-gif:1.3.0"
compile "com.facebook.fresco:animated-base-support:1.3.0"
这解决了调试构建的问题,但如果您想在发布构建中也解决该问题,则必须将以下行添加到您的 proguard-rules 文件中:
-keep class com.facebook.imagepipeline.animated.factory.AnimatedFactoryImpl { public AnimatedFactoryImpl(com.facebook.imagepipeline.bitmaps.PlatformBitmapFactory, com.facebook.imagepipeline.core.ExecutorSupplier); }
有关于此的更多信息,请参见此处:https://github.com/facebook/fresco/issues/1177 https://github.com/facebook/fresco/issues/1177
这是固定的commit https://github.com/facebook/fresco/commit/0d0c5757ff40eb9e9f23533c9798dcdde095ce86并将包含在下一个版本中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)