由于这个问题只在安卓系统中出现,建议解决这个问题的方法是专门针对安卓系统使用Platform:
import {Platform, StatusBar} from 'react-native'
const styles = StyleSheet.create({
container: {
flex: 1,
...Platform.select({
android: {
marginTop: StatusBar.currentHeight
}
})
}
})
其中container是应用程序中的主容器.
<View style={styles.container}>
// rest of the code here
</View>