Bacancy Technology
Bacancy Technology represents the connected world, offering innovative and customer-centric information technology experiences, enabling Enterprises, Associates and the Society to Rise™.
12+
Countries where we have happy customers
1050+
Agile enabled employees
06
World wide offices
12+
Years of Experience
05
Agile Coaches
14
Certified Scrum Masters
1000+
Clients projects
1458
Happy customers
Artificial Intelligence
Machine Learning
Salesforce
Microsoft
SAP
May 31, 2023
In React Native, we have some methods to resize the image to fit entirely on the screen.
The tag, by default, uses the resize mode to be “cover”.
If we want to achieve the image to fit on the screen without any area being cropped, then we can use the resize mode “contain”.
Here is how you can do this:
Instead of giving some random value for the height and width, You can use the “Dimensions” method from React Native, which gives you access to the height and width of the device.
import {Dimensions, Image} from 'react-native';
Now inside your component
const dimensions = Dimensions.get('window'); const imageWidth = dimensions.width; const imageHeight = dimensions.height; return ( <Image style={{height: imageHeight, width: imageWidth}} resizeMode="contain" source={{ uri: 'https://asia.olympus-imaging.com/content/000107506.jpg', }} /> );
if you want to set the image to take the whole screen area, you can use the
resizeMode="cover"
or you can remove the resizeMode tag as by default the image takes the resizeMode to be cover.
For More Information: Image in React Native