react native asign width to image
import { Dimensions } from "react-native";
const win = Dimensions.get('window');
<Image
style={{
width: win.width/2,
height: win.width/2,
resizeMode: "contain",
alignSelf: "center",
borderWidth: 1,
borderRadius: 20,
}}
source={{uri:'https://facebook.github.io/react/img/logo_og.png'}}
resizeMode="stretch"
/>First import Dimensions from react-native
import { Dimensions } from 'react-native';
then you have to get the dimensions of the window
const win = Dimensions.get('window');
Now calculate ratio as
const ratio = win.width/541; //541 is actual image width
now the add style to your image as
imageStyle: {
width: win.width,
height: 362 * ratio, //362 is actual height of image
}
Also in JavaScript:
- settimeout in vuejs
- difference between React Native and React
- export apk react native
- how to get utc time in angular
- flat function javascript
- how to use fetch() javascript
- how to get class name in jquery
- uncheck checkbox when another is checked javascript
- scroll div horizontally with move wheel js
- expo app.json
- math.floor
- how to remove last index of array in javascript
- jquery: get selected option of the drop down list
- clear form inside modal after close reactjs
- react native componentwillmount vs componentdidmount
- Iterate with JavaScript For Loops
- How to make PWAs installable js
- javascript nameof
- react native init specific version
- get selected value on componentdidmount reactjs
- get date in javascript
- node save json to file
- explain js es6
- service worker js example