I set the StatusBar to translucent in order to draw the app’s content under the status bar (on Android 14 and earlier — Android 15 enforces edge-to-edge design by default).
According to the React Native documentation:
For Android, the window dimensions will exclude the size used by the status bar (if not translucent) and bottom navigation bar.
https://reactnative.dev/docs/dimensions#get
However, in my tests, the window height still excludes the status bar area, even though the status bar is set to translucent using the translucent prop of StatusBar.
Is this a bug, or is there something I’m missing?
My test was using this App.tsx file on a dummy react native project and run on an Android device.
To test, please install react-native-safe-area-context.
App.tsx
import React from 'react';
import { Dimensions, StatusBar, StyleSheet, Text, useColorScheme, View, } from 'react-native';
import { SafeAreaProvider, SafeAreaView, useSafeAreaInsets } from 'react-native-safe-area-context';
const ContentView = () => {
const insets = useSafeAreaInsets();
const heightPercentage = (percentage: number) => (Dimensions.get('window').height - insets.top - insets.bottom) * percentage / 100;
const widthPercentage = (percentage: number) => (Dimensions.get('window').width - insets.left - insets.right) * percentage / 100;
const CustomStatusBar = (): React.JSX.Element => {
return <View style={{ height: insets.top, width: widthPercentage(100), backgroundColor: 'red' }}>
<SafeAreaView>
<StatusBar barStyle='dark-content' translucent backgroundColor='transparent' />
</SafeAreaView>
</View>
};
const BottomBar = (): React.JSX.Element => {
return <View style={{ height: insets.bottom, width: widthPercentage(100), backgroundColor: 'red' }} />
}
const LeftBar = (): React.JSX.Element => {
return <View style={{ height: heightPercentage(100), width: insets.left, backgroundColor: 'red' }} />
}
const RightBar = (): React.JSX.Element => {
return <View style={{ height: heightPercentage(100), width: insets.right, backgroundColor: 'red' }} />
}
return (
<View style={{ flex: 1, backgroundColor: 'red' }}>
<CustomStatusBar />
{/* content */}
<View style={{ flexDirection: 'row', height: heightPercentage(100), width: widthPercentage(100) }}>
<LeftBar />
{/* content */}
<View style={{
backgroundColor: 'green',
height: heightPercentage(100),
width: widthPercentage(70),
justifyContent: 'center',
paddingLeft: widthPercentage(2)
}}>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>top: {insets.top}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>right: {insets.right}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>bottom: {insets.bottom}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>left: {insets.left}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>StatusBar's height: {StatusBar.currentHeight}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>window's heihgt: {Dimensions.get('window').height}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>screen's heihgt: {Dimensions.get('screen').height}</Text>
<Text style={{ color: 'white', fontSize: heightPercentage(2) }}>heightPercentage(100): {heightPercentage(100)}</Text>
</View>
<RightBar />
</View>
<BottomBar />
</View>
);
}
function App(): React.JSX.Element {
return (
<SafeAreaProvider style={{ flex: 1 }}>
<ContentView />
</SafeAreaProvider>
);
}
export default App;