Add animated background on your react-native component
$ npm install react-native-animated-background --save
$ react-native link react-native-animated-background
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-animated-background
and add RNAnimatedBackground.xcodeproj
libRNAnimatedBackground.a
to your project’s Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.reactlibrary.RNAnimatedBackgroundPackage;
to the imports at the top of the filenew RNAnimatedBackgroundPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-animated-background'
project(':react-native-animated-background').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-animated-background/android')
android/app/build.gradle
:
compile project(':react-native-animated-background')
//Note that each component can be imported separately
import RNAnimatedBackground from "react-native-animated-background";
import {
RNAnimatedBgColor,
RNAnimatedBgSeq,
RNAnimatedShapeBgColor,
RNAnimatedCircleBgSeq,
RNAnimatedTriangleBgSeq,
} from "react-native-animated-background";
// TODO: What to do with the module?
export default function App() {
return (
<ScrollView style={styles.container}>
<StatusBar style="auto" ></StatusBar>
<RNAnimatedBgColor
firstColor="red"
secondColor="green"
borderWidth={5}
elevation={8}
width={200}
height={200}
>
<Text>Open up App.js to start working on your app!</Text>
</RNAnimatedBgColor>
<RNAnimatedShapeBgColor
firstColor="blue"
secondColor="yellow"
borderWidth={5}
borderRadius={20}
elevation={8}
margin={5}
width={200}
height={200}
>
<Button
onPress={() => Alert.alert("I love RNAnimatedBorder!")}
title="press me"
/>
</RNAnimatedShapeBgColor>
<RNAnimatedBgColor
firstColor="pink"
secondColor="orange"
borderWidth={20}
elevation={8}
margin={5}
width={300}
height={200}
>
<View
style={{ width: 100, height: 100, backgroundColor: "black" }}
></View>
</RNAnimatedBgColor>
<RNAnimatedBgSeq
numbShapes={100}
backgroundColor="purple"
width={40}
height={40}
elevation={5}
>
<Text
style={{
alignSelf: "center",
position: "absolute",
backgroundColor: "green",
fontSize: 20,
fontWeight: "bold",
color: "white",
textAlign: "center",
elevation: 8,
}}
>
react-native-animated-background
</Text>
</RNAnimatedBgSeq>
<RNAnimatedCircleBgSeq
numbShapes={100}
backgroundColor="yellow"
width={40}
elevation={5}
>
<Text
style={{
alignSelf: "center",
position: "absolute",
backgroundColor: "green",
fontSize: 20,
fontWeight: "bold",
color: "white",
textAlign: "center",
elevation: 8,
}}
>
react-native-animated-background
</Text>
</RNAnimatedCircleBgSeq>
<RNAnimatedTriangleBgSeq
numbShapes={100}
backgroundColor="red"
color="skyblue"
borderLeftWidth={26}
elevation={5}
>
<Text
style={{
alignSelf: "center",
position: "absolute",
backgroundColor: "green",
fontSize: 20,
fontWeight: "bold",
color: "white",
textAlign: "center",
elevation: 8,
}}
>
react-native-animated-background
</Text>
</RNAnimatedTriangleBgSeq>
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
},
});