如何在android端设置加载gif的动画?
因此,我的React原生项目中有一个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
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'