Does anyone know a way to make Android Status Bar transparent with React Native?
NOT TRANSLUCENT, Transparent.
I am using react-navigation too.
Does anyone know a way to make Android Status Bar transparent with React Native?
NOT TRANSLUCENT, Transparent.
I am using react-navigation too.
Just use it like this: Tested with: "react-native": "0.60.4" and "0.61.5"
<StatusBar translucent backgroundColor="transparent" />
This is working for me on android
<StatusBar
backgroundColor="transparent"
translucent={true}
/>
Unless you are using Statusbar as a component, try this method.
useFocusEffect(
useCallback(() => {
StatusBar.setBarStyle("dark-content");
Platform.OS === 'android' && StatusBar.setBackgroundColor('transparent');
StatusBar.setTranslucent(true);
}, []),
);
Do not forget to give some paddingTop
to the most outer View
.
<StatusBar translucent backgroundColor="transparent" />
is the way to go, thx to @Felipe Rugai
However, 2 things to know:
<Header />
component from react-native-elements
, it already have <StatusBar />
included, using its statusBarProps
instead.<StatusBar />
hence doesn't work well.If you're talking about the status bar of the OS (the one you pull down to access wifi/bluetooth/settings etc), try adding this to you MainActivity.java:
private void hideNavigationBar() {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
And you can call that^ function in this function from the same MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
hideNavigationBar();
}
However, if you're talking about the StatusBar of the app, try adding this to your App.js file
static navigationOptions = {
header: null
}
This solution can solve the issue if you're working with expo in your package JSON /expo configuration: you can add a property to overwrite the default StatusBar for android
"androidStatusBar":{
"translucent":false
}
Try this to make transparent statusbar in android
container: {
flex:1,
paddingTop: 20
},
add display flex and paddingTop to your main View
component
In react native, if you are using expo you can go to the app.json file and add status bar color. After this background color of the status bar for the complete app will change.
"androidStatusBar": {
"backgroundColor": "#105846"
},
Check the linked page.