1、引入
import { StyleSheet, Text, SafeAreaView } from 'react-native';
2、使用
设置 SafeAreaView 的样式,flex:1即可
<SafeAreaView style={styles.container}>
<Text>Page content</Text>
</SafeAreaView>
代码示例:
import React from 'react';
import { StyleSheet, Text, SafeAreaView } from 'react-native';
const App = () => {
return (
<SafeAreaView style={styles.container}>
<Text>Page content</Text>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
},
});
export default App;