【发布时间】:2021-04-09 05:11:58
【问题描述】:
我需要将<View> 和position: 'absolute' 放在一起,这样它就可以覆盖下面的另一个视图。我希望它不会出现在 iOS 的状态栏后面,所以我将所有内容都放在了 <SafeAreaView> 中。
不幸的是,绝对位置似乎是相对于全屏而不是其父视图(SafeAreaView)。
有什么诀窍吗?
const styles = StyleSheet.create({
safeAreaView: {
flex: 1,
},
map: {
flex: 1,
},
userLocationButton: {
position: 'absolute',
right: 12,
top: 12,
},
});
return (
<SafeAreaView style={styles.safeAreaView}>
<ClusteredMapView style={styles.map} />
)}
<TouchableOpacity style={styles.userLocationButton}>
<Image source={UserLocationButton} />
</TouchableOpacity>
)}
</SafeAreaView>
);
【问题讨论】:
标签: react-native absolute safeareaview