React 原生动画 api 不适用于 android 手机
React native animated api not working on android phones
所以,我尝试使用 react-native-animated
API 制作淡入淡出动画,但不幸的是,当我尝试在我的 android 设备上渲染它时,它没有动画。它只是不动画任何东西,屏幕也是空白的,但一段时间后(比如 30-40 秒),文本显示时没有动画。如果我不应用 Animated.View,那么文本会立即显示,或者您可以说是内容的正常呈现。任何人都可以发现我在这段代码中做错了什么,或者我还应该添加什么来使它工作。
react-native-animatable 版本:1.3.3
import React, { Component } from 'react';
import { Text, View, ScrollView } from 'react-native';
import { Card, } from 'react-native-elements';
import * as Animatable from 'react-native-animatable';
function History() {
return(
<View>
<Text style = {{margin:10}}>
Started in 2010, Eatsy quickly established itself as a culinary icon par excellence in Hong Kong. With its unique brand of world fusion cuisine that can be found nowhere else, it enjoys patronage from the A-list clientele in Hong Kong. Featuring four of the best three-star Michelin chefs in the world, you never know what will arrive on your plate the next time you visit us.
</Text>
</View>
);
}
class Test extends Component{
render()
{
return(
<ScrollView>
<Animatable.View animation="fadeInDown" duration={2000} delay={1000}>
<Card title ='Our History'>
<History />
</Card>
</Animatable.View>
</ScrollView>
);
}
};
export default Test;
好的,现在我在浏览互联网几个小时后知道了解决方案,你只需在 <Animatable.View>
中添加 useNativeDriver='true'
就像这样:
<Animatable.View animation="fadeInUp" useNativeDriver='true' duration={2000} delay={1000}>
所以,我尝试使用 react-native-animated
API 制作淡入淡出动画,但不幸的是,当我尝试在我的 android 设备上渲染它时,它没有动画。它只是不动画任何东西,屏幕也是空白的,但一段时间后(比如 30-40 秒),文本显示时没有动画。如果我不应用 Animated.View,那么文本会立即显示,或者您可以说是内容的正常呈现。任何人都可以发现我在这段代码中做错了什么,或者我还应该添加什么来使它工作。
react-native-animatable 版本:1.3.3
import React, { Component } from 'react';
import { Text, View, ScrollView } from 'react-native';
import { Card, } from 'react-native-elements';
import * as Animatable from 'react-native-animatable';
function History() {
return(
<View>
<Text style = {{margin:10}}>
Started in 2010, Eatsy quickly established itself as a culinary icon par excellence in Hong Kong. With its unique brand of world fusion cuisine that can be found nowhere else, it enjoys patronage from the A-list clientele in Hong Kong. Featuring four of the best three-star Michelin chefs in the world, you never know what will arrive on your plate the next time you visit us.
</Text>
</View>
);
}
class Test extends Component{
render()
{
return(
<ScrollView>
<Animatable.View animation="fadeInDown" duration={2000} delay={1000}>
<Card title ='Our History'>
<History />
</Card>
</Animatable.View>
</ScrollView>
);
}
};
export default Test;
好的,现在我在浏览互联网几个小时后知道了解决方案,你只需在 <Animatable.View>
中添加 useNativeDriver='true'
就像这样:
<Animatable.View animation="fadeInUp" useNativeDriver='true' duration={2000} delay={1000}>