Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在android端设置加载gif的动画?_Android_React Native - Fatal编程技术网

如何在android端设置加载gif的动画?

如何在android端设置加载gif的动画?,android,react-native,Android,React Native,因此,我的React原生项目中有一个gif: import React from "react"; import { View, StyleSheet, Image } from "react-native"; import PropTypes from "prop-types"; const Loading = () => ( <View style={styles.container}> <Image source={require("./Loading

因此,我的React原生项目中有一个gif:

import React from "react";
import { View, StyleSheet, Image } from "react-native";
import PropTypes from "prop-types";

const Loading = () => (
  <View style={styles.container}>
    <Image source={require("./Loading.gif")} style={styles.containerLoader} />
  </View>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    color: "#00AD50"
  },
  containerLoader: {
    width: 150,
    height: 150
  }
});

export { Loading };
但是上面的操作并没有使gif动画化。因此,虽然此处将其作为解决方案引用:

这对我不起作用。

还要检查您是否正在使用react native 0.60+

简而言之,参考正确的壁画版本很重要:

// For animated GIF support
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'

这不是一个解决方案,而是一个建议,您可以尝试使用lottie for react native。gif使用量大,尺寸大。lottie动画更平滑,占用空间更少。如果可行,请尝试!可能重复的
// For animated GIF support
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'