When I use in react-native it gives warning that using with children is deprecated and will be error in future. User instead.
So, If I use it doesn't give expected result which I was getting using
Here is the code I wrote for using
<ImageBackground source={require('../../img/splash/splash_bg.png')} style={styles.backgroundImage} > </ImageBackground>
And style code is
const styles = StyleSheet.create({ backgroundImage: { flex: 1, // width: undefined, // height: undefined, // flexDirection: 'column', // backgroundColor:'transparent', // justifyContent: 'flex-start', },}
Approach: In this article, we will see that how to set background Image in react-native. In our project, we will simply set a background image and show a text input on top of it. Step 2: Create a components folder inside your project. Inside the components, folder create a file BackgroundImage.
How to use ImageBackground. The ImageBackground component accepts mostly the same props as the Image component with a few differences. The style prop is applied to a view that wraps an inner image; the imageStyle prop is applied to the image itself. The imageRef prop also is applied to the inner image.
You can change the background of main activity/screen, by specifying backgroundColor attribute of stylesheet design in parent view layout (or RoorView) . This will make App's starting screen look and feel better.
You can use "ImageBackground" component on React Native.
<ImageBackground source={yourSourceFile} style={{width: '100%', height: '100%'}} > <....yourContent...> </ImageBackground>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With