How To Create Fullscreen Image Background In React Native?

Hello guys, In this example, we will see how you can create Fullscreen Image Background in React Native app. It is very easy so let's start with it without wasting any time.




So first of all we need to create a fresh project using cli.
npx react-native init fullScreenImageBackground
Go to the project directory.
cd fullScreenImageBackground
After this, try to run that blank project on both iOS and android devices. 
npx react-native run-ios  (mac only)
npx react-native run-android
If everything ok, you will see blank React Native app as shown in image.

Now, install NativeBase library for UI purposes.
yarn add native-base
Link the project assets. 
npx react-native link
So after that you need to replace App.js with this code. 
import React, {Component} from 'react';
import {Content, Text, H1, H2, H3} from 'native-base';
import {ImageBackground} from 'react-native';
export default class App extends Component {
  render() {
    return (
      <ImageBackground
        style={{flex: 1}}
        // For External/ Remote Images
        source={{
          uri:
            'https://cdn.pixabay.com/photo/2019/05/19/23/47/clouds-4215608_960_720.jpg',
        }}>
        <Content padder>
          <Text style={{textAlign: 'center'}}>
            Example Of Full Screen Background Image
          </Text>
          <ImageBackground style={{flex: 1}} source={require('./image.jpg')}>
            <H1>Components</H1>
            <H2>Background</H2>
            <H3>Full</H3>
            <Text>Image</Text>
          </ImageBackground>
        </Content>
      </ImageBackground>
    );
  }
}
Save everything and run the project again by using following commands.
npx react-native run-ios  (mac only)
npx react-native run-android
You will see your Fullscreen Image Background app is ready and showing in the simulators (or devices). Output images are attached and link to the video of the project's coding as given below.

I hope you like the article regarding Image Background. This is how you can create it in the React Native app for Android and iOS. If you have any questions or you want to get a tutorial on some topic, you can comment below.
There will be more posts coming soon. Stay tuned! Bye. 🙂

Post a Comment

0 Comments