skip to Main Content

I’m building React Native app with Expo. I’m using version 51 of the Expo. When I ran the app for the first time, there was already some templates. I wanted to change the color of SafeAreaView at the top (and bottom on iPhone devices) but I don’t know where to do so since there is already safe area applied by default and I don’t know where to change it. I’m using the App router. Also when I add new screen and wrap it with SafeAreaView, it just shift my screen down little bit creating empty space between actual safe area (notch on the phone) and my content.

For example adding wrapper of SafeAreaView to my screen like this, creates the empty space as you can see in the image.

 <SafeAreaView style={{ flex: 1, backgroundColor: "olive" }}>

enter image description here

2

Answers


  1. The purpose of SafeAreaView is to render content within the safe area boundaries of a device.

    So if you want to apply the background color everywhere, you may do this instead :

    <View style={{ flex: 1, backgroundColor: "olive" }}>
        <SafeAreaView style={{ flex: 1 }}>
            {/* ... */}
        </SafeAreaView>
    </View>
    
    Login or Signup to reply.
  2. you can check with global styling with SafeAreaProvider, it manages safe areas across your entire app, use https://www.npmjs.com/package/react-native-safe-area-context package for SafeAreaProvider and SafeAreaView components. wrap your app.jsx/tsx with SafeAreaProvider.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search