react-native: Position absolute view is not covering `
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
Yes
Environment
react-native -v
: 0.47.1 and 0.48.1node -v
: v.7.5.0npm -v
: 5.3.0yarn --version
: N/A
Then, specify:
- Target Platform: Android
- Development Operating System: Windows 10
- Build tools: N/A
Steps to Reproduce
(Write your steps here:)
- Code:
import React, { Component } from 'react';
import { AppRegistry, View, StyleSheet, Text, ActivityIndicator, Button } from 'react-native';
export default class App extends Component {
render() {
return (
<View style={styles.wrap}>
<Button title='Enabled' onPress={this.handleSubmit} />
<Text>{'\n'}</Text>
<Text>{'\n'}</Text>
<Text>{'\n'}</Text>
<Text>{'\n'}</Text>
<Button title='Disabled' onPress={this.handleSubmit} disabled />
<View style={styles.loadingWrap}>
<ActivityIndicator color="deepskyblue" size={50} />
</View>
</View>
)
}
handleSubmit = () => alert('hi')
}
const styles = StyleSheet.create({
wrap: {
flex: 1,
width: '100%',
justifyContent: 'center'
},
loadingWrap: {
position: 'absolute',
height: '100%',
width: '100%',
backgroundColor: 'rgba(0, 0, 0, 0.8)',
justifyContent: 'center'
}
})
AppRegistry.registerComponent('interactable', () => App)
Expected Behavior
I thought the <View>
would cover the <Button>
becuase it comes after the button in the hierarchy.
Actual Behavior
View is not covering Button.
Reproducible Demo
Demo - https://snack.expo.io/BJHX7-15-
(Paste the link to an example project and exact instructions to reproduce the issue.)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (1 by maintainers)
@Noitidart I’m working in a similar mockup that needs to have an absolute View over two different View containers.
The problem: An absolute component does not mean that is over the other ones. The solution: Just give a
zIndex: 1
to the same element you made absolute, now the button or even touchable elements will work.Hope it helps anyone having this problem!