Resizing images
The width
and height
style properties of Image
components determine the size of what's rendered on the screen. For example, you'll probably have to work with images at some point that have a larger resolution than you want to be displayed in your React Native application. Simply setting the width
and height
style properties on the Image
is enough to properly scale the image.
Let's look at some code that lets you dynamically adjust the dimensions of an image using controls:
import React, { useState } from "react"; import { View, Text, Image } from "react-native"; import Slider from "@react-native-community/slider"; import styles from "./styles"; export default function App() { const source = require("./images/flux.png"); const [width, setWidth] = useState(100); const [height, setHeight] = useState(100); return ( <View style...