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;

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐