You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<Text style={styles.paragraph}>This is top text.</Text>
83
+
<Text style={styles.paragraph}>This is bottom text.</Text>
92
84
</SafeAreaView>
93
85
```
94
86
95
87
`forceInset` takes an object with the keys `top | bottom | left | right | vertical | horizontal` and the values `'always' | 'never'`. Or you can override the padding altogether by passing an integer.
96
88
97
89
There is also a [Snack](https://snack.expo.io/@react-navigation/react-navigation-docs:-safeareaview-demo-v3) available to demonstrate how `forceInset` behaves.
90
+
91
+
## Android notches
92
+
93
+
React Native does not currently expose an API to access information about device cutouts on Android devices. If your app has have an opaque status bar (the default in React Native), that may handle the area where the device has its cutout without any further work required. If not, to workaround this you may want to use the following temporary workaround:
- Check if the device has a notch with `DeviceInfo.hasNotch()` - this compares the device brand and model to a list of devices with notches - a crude but effective workaround.
97
+
- If the device has a notch, you may want to increase the status bar height known to the SafeAreaView by doing something like this:
98
+
99
+
```js
100
+
import { Platform } from'react-native';
101
+
import { SafeAreaView } from'react-navigation';
102
+
importDeviceInfofrom'react-native-device-info';
103
+
104
+
if (Platform.OS==='android'&&Device.hasNotch()) {
105
+
SafeAreaView.setStatusBarHeight(
106
+
/* Some value for status bar height + notch height */
107
+
);
108
+
}
109
+
```
110
+
111
+
Work is in progress on a longer term solution, see [this pull request](https://github.com/facebook/react-native/pull/20999) for more information.
<Text style={styles.paragraph}>This is top text.</Text>
84
+
<Text style={styles.paragraph}>This is bottom text.</Text>
93
85
</SafeAreaView>
94
86
```
95
87
96
88
`forceInset` takes an object with the keys `top | bottom | left | right | vertical | horizontal` and the values `'always' | 'never'`. Or you can override the padding altogether by passing an integer.
97
89
98
90
There is also a [Snack](https://snack.expo.io/@react-navigation/react-navigation-docs:-safeareaview-demo-v3) available to demonstrate how `forceInset` behaves.
91
+
92
+
## Android notches
93
+
94
+
React Native does not currently expose an API to access information about device cutouts on Android devices. If your app has have an opaque status bar (the default in React Native), that may handle the area where the device has its cutout without any further work required. If not, to workaround this you may want to use the following temporary workaround:
- Check if the device has a notch with `DeviceInfo.hasNotch()` - this compares the device brand and model to a list of devices with notches - a crude but effective workaround.
98
+
- If the device has a notch, you may want to increase the status bar height known to the SafeAreaView by doing something like this:
99
+
100
+
```js
101
+
import { Platform } from'react-native';
102
+
import { SafeAreaView } from'react-navigation';
103
+
importDeviceInfofrom'react-native-device-info';
104
+
105
+
if (Platform.OS==='android'&&Device.hasNotch()) {
106
+
SafeAreaView.setStatusBarHeight(
107
+
/* Some value for status bar height + notch height */
108
+
);
109
+
}
110
+
```
111
+
112
+
Work is in progress on a longer term solution, see [this pull request](https://github.com/facebook/react-native/pull/20999) for more information.
0 commit comments