I use the default components View and Navigator. Wrapping the Navigator inside a View, I want it to automatically get the height of the content (Navigator), but if I don't set an explicit height for the View component - the Navigator does not show, as if it had position: absolute.
If I add a Text component inside a View - the View automatically gets the height from the child Text component. But if I set 'height: auto' for View - this property doesn't work.
render() {
return (
<View style={{height: 'auto', backgroundColor: 'powderblue'}}>
<Navigator
initialRoute={{ title: 'My Initial Scene', index: 0 }}
renderScene={(route, navigator) => {
return (
<MyScene title={route.title} />
)
}}
/>
</View>
)
}
ViewPager found in the support library. If you are using ViewPager for flipping static height layouts then you can simply add height flag as hardcoded like: If you want to use ViewPager for flipping the layouts having different heights then this blog will be helpful to you.
05-02-2017 11:30 AM There is no auto-height for the gallery itself - the height of the gallery control is fixed. However, you can use what we call a gallery with flexible height, where the template (that is replicated for all items) can have different heights.
1. Use custom gallery - Flexible Height 2. Use following expression for control's height - Len (ThisItem.Column)/N a. N - Try different denominators to set the height
You need to create a gallery that has that property, once the gallery is added you cannot change whether it has a flexible height template or not. To add one, choose the last option in the gallery menu in the Insert tab: When you have that, you can add controls that have the AutoHeight property (text box, HTML Text) to the gallery template.
style={{height:'auto'}}
will not work. You must use an integer or use flex
. Here you can see an example of the options.
https://facebook.github.io/react-native/docs/height-and-width.html
Your code will look like this:
render() {
return (
<View style={{flex:1, backgroundColor: 'powderblue'}}>
<Navigator
style={{flex:1}}
initialRoute={{ title: 'My Initial Scene', index: 0 }}
renderScene={(route, navigator) => {
return (
<MyScene
title={route.title}
/>
)
}
}
/>
</View>
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With