Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting component height to 100% in react-native

Tags:

react-native

I can give the height element of style numeric values such as 40 but these are required to be integers. How can I make my component to have a height of 100%?

like image 698
lhahne Avatar asked Mar 29 '15 08:03

lhahne


People also ask

How do you set full width in React Native?

To add a full width button with flex-box in React Native, we can set the alignSelf style to 'stretch' . to add a Button with the alignSelf style set to 'stretch' to make the button stretch to the width of the screen.

How do you make a div full height in react?

To set a Div's height to cover the full screen in React, set its height to 100vh , e.g. <div style={{height: '100vh'}}>... </div> . When the height of the element is set to 100vh , it covers 100% of the viewport's height.

How do you set the height of a component in react?

In react native application, to set the dimensions of a component, we use width and height properties. Remember, all the values of dimensions are unitless like we can't use height: 20px to set the height of a component instead of we just use height: 20 and react-native automatically set the pixels.


1 Answers

check out the flexbox doc. in the stylesheet, use:

flex:1, 
like image 142
wangii Avatar answered Sep 29 '22 22:09

wangii