问题
Trying to add elevation (shadow) to View works, however my second View, which renders circle, hides under View with elevation property. If elevation is removed, circle with position: 'absolute' is working properly.
Any ideas how to use elevation and position View absolute?
My Code:
import React, { Component } from 'react';
import { StyleSheet, Text, View, Platform, TouchableOpacity } from 'react-native';
import { Font } from 'expo';
export default class Position extends Component {
render() {
return (
<View style={{ flex: 1, marginTop: 25 }}>
<View style={{ height: 50, backgroundColor: 'red', elevation: 3}}/>
<View style={styles.circle}><Text>HELLO</Text></View>
</View>
);
}
}
const styles = StyleSheet.create({
circle: {
position: 'absolute',
backgroundColor: 'yellow',
width: 60,
height: 60,
top: 30,
borderRadius: 100,
alignSelf: 'center',
justifyContent: 'center',
alignItems: 'center',
}
});
回答1:
Found resolution by adding elevation to circle View as well.
来源:https://stackoverflow.com/questions/51821016/react-native-elevation-and-position-absolute