// Firstly, import Dimensions, and save the window's width and height
import {Dimensions} from "react-native";
var width = Dimensions.get("window").width;
var height = Dimensions.get("window").height;
// Then inside your stylesheet you can use something like this:
width: width * 0.9, // Sets width to 90%
import React from 'react';
import { View } from 'react-native';
const PercentageDimensionsBasics = () => {
// Try removing the `height: '100%'` on the parent View.
// The parent will not have dimensions, so the children can't expand.
return (
<View style={{ height: '100%' }}>
<View style={{
height: '33%', backgroundColor: 'red'
}} />
<View style={{
width: '66%', height: '35%', backgroundColor: 'blue'
}} />
<View style={{
width: '20%', height: '50%', backgroundColor: 'yellow'
}} />
</View>
);
};
export default PercentageDimensionsBasics;