Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

relative width and height image react native

const dimensions = Dimensions.get('window');
const imageHeight = Math.round(dimensions.width * 9 / 16);
const imageWidth = dimensions.width;

return (
   <Image
     style={{ height: imageHeight, width: imageWidth }}
   />
);
Comment

react native image auto height

import {
  Image,
  Dimensions,
} from "react-native";


const screen = Dimensions.get("window");
Image.getSize(this.state.image_url, (width, height) => {
  //full image to screen width (Change screen.width to pixel you want)
  let imageWidthRatio = width / screen.width; 
  let imageHeight = height / imageWidthRatio;
  this.setState({ width: screen.width, height: imageHeight });
});

<Image
	style={{
       width: this.state.width,
       height: this.state.height,
       alignSelf: "center",
    }}
    source={{ uri: this.state.image_url }}
/>
Comment

PREVIOUS NEXT
Code Example
Javascript :: get full date in javascript 
Javascript :: jquery page finished loading 
Javascript :: js sound 
Javascript :: get DOM node with xpath 
Javascript :: react overflow scroll 
Javascript :: jquery if element is clicked 
Javascript :: javascript truncate string full word 
Javascript :: ERR_REQUIRE_ESM 
Javascript :: longest word javascript 
Javascript :: hide and show modal jquery 
Javascript :: how to print the value of variable in javascript in html 
Javascript :: json data doesn show on console 
Javascript :: javascript sort object by key 
Javascript :: javascript phone number mask 
Javascript :: jquery open image in new tab 
Javascript :: js check if obj all false 
Javascript :: last position of array javascript 
Javascript :: detect user browser javascript 
Javascript :: are you sure you want to proceed click ok button javascript code 
Javascript :: javascript get second last element in array 
Javascript :: iterate object keys javascript 
Javascript :: get a href value javascript 
Javascript :: postgresql update json field key value 
Javascript :: node get current url 
Javascript :: react native get navigation bar height 
Javascript :: how to delete a folder in node js 
Javascript :: javascript array of zeros of n length 
Javascript :: js delete object in dict 
Javascript :: check if body has class javascript 
Javascript :: get value of div jquery 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =