First, define Dimensions.
import { Dimensions } from "react-native";
var width = Dimensions.get('window').width; //full width
var height = Dimensions.get('window').height; //full height
then, change line1 style like below:
line1: {
backgroundColor: '#FDD7E4',
width: width,
},
import { Dimensions } from 'react-native';
width: ${(Dimensions.get('window').width)}px;
import React from 'react'
import { View } from 'react-native'
export default function index() {
const onLayout=(event)=> {
const {x, y, height, width} = event.nativeEvent.layout;
}
return (
<View onLayout={onLayout}>
<OtherComponent />
</View>
)
}
header : {
height : 100,
backgroundColor: "favorite color",
alignSelf: "stretch",
}
import React from 'react';
import { View } from 'react-native';
const Dimensions = () => {
return (
<View>
<View style={{
width: 50, height: 50, backgroundColor: 'powderblue'
}} />
<View style={{
width: 100, height: 100, backgroundColor: 'skyblue'
}} />
<View style={{
width: 150, height: 150, backgroundColor: 'steelblue'
}} />
</View>
);
};
export default Dimensions;
line1:{
alignSelf: 'stretch',
}