React Native Image Opacity Example

Aug 16, 2022 . Admin



Now, let's see tutorial of example of set image opacity transparency in react native. if you want to see example of react native image opacity example then you are a right place. Here you will learn react native image opacity. you'll learn how to make image opacity in react native.

In this example,we will set image opacity in react native.we will add to css 'opacity' to image then display to mobile app.The less the value is the more opacity effect apply on image.let's below example.

Step 1: Download Project

In the first step run the following command to create a project.

expo init ExampleApp
Step 2: App.js

In this step, You will open the App.js file and put the code.

import React from 'react';
import { StyleSheet, Text, View, Image } from 'react-native';

export default function App() {

    return (
      <View style={styles.container}>
        <Image
        style={styles.img}
        source={require('./assets/images.jpeg')}
      	/>
      </View>
    );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  
  img: {
    height: 200,
    width: 200,
    opacity: 0.6
  }
});
Step 3: Run Project

In the last step run your project using the below command.

expo start

You can QR code scan in Expo Go Application on mobile.

Output:

It will help you...

#React Native