How to bring absolutely positioned elements/components on top of other components which are rendered after that .
I am using scrollview
component
style:
width: 300,
height: 100,
position:'absolute',
top:30,
but other components are overlapping the scroll dropdown .
I changed top to Bottom but the components which were on the top of scrollview
are not getting overlapped.
As I am new to this react-native and unaware of reactjs
I am unable to figure out solution and terms to express my problem please help.
I have attached screen shot of my problem in the below image I have a society dropdown in scrollview
component and area is another scrollview which is visible and overlaps the first component
zIndex
property is supported as of react-native version 0.29.0. Check the documentation.
zIndex controls which components display on top of others. Normally, you don't use zIndex. Components render according to their order in the document tree, so later components draw over earlier ones. zIndex may be useful if you have animations or custom modal interfaces where you don't want this behavior.
It works like the CSS z-index property - components with a larger zIndex will render on top. Think of the z-direction like it's pointing from the phone into your eyeball. See https://developer.mozilla.org/en-US/docs/Web/CSS/z-index for more details.
On iOS, zIndex may require Views to be siblings of each other for it to work as expected.
I had a similar issue and it came from the fact that the zIndex wasn't applied to the right component. For instance if you have the following:
class App extends Component {
render () {
return (
<View style={styles.form}>
<View style={styles.selectInput}>
<TextInput placeholder="Select something" />
<Dropdown />
</View>
<View style={styles.formInput}>
<TextInput placeholder="Stuff" />
</View>
<View style={styles.formInput}>
<TextInput placeholder="Other stuff" />
</View>
</View>
);
}
}
And you want your Dropdown
component to go above the 2 form inputs below, you need to add zIndex: 100
to its container, the View with selectInput
style.
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