我需要放置一个<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>
);
我有同样的问题,通过用另一个View包裹绝对元素来解决。
<SafeAreaView style={{flex: 1}}>
<View style={{flex: 1}}>
<TouchableOpacity style={{height: 40, width: 40, borderRadius: 20}} />
</View>
</SafeAreaView>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句