Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the Android status bar color with React Native?

I just got started with React Native for Android, and I'm trying to figure out if there's a way to change the status bar color for Android...

Like this?

enter image description here

like image 917
russjr08 Avatar asked Sep 23 '15 22:09

russjr08


People also ask

Can you change the color of the status bar Android?

Step 1: After opening the android studio and creating a new project with an empty activity. Step 2: Navigate to res/values/colors. xml, and add a color that you want to change for the status bar.

How do you make the status bar white React Native?

Add import { StatusBar } from 'react-native'; to the top of your app. js and then add StatusBar. setBarStyle('light-content', true); as the first line in your render() to change the status bar text/icons to white.

How do I show status bar in React Native?

React Native StatusBar PropsIt is used to hide and show the status bar. By default, it is false. If hidden = {false} it is visible, if hidden = {true}, it hide the status bar. It sets the background color of the status bar.

How do I change the color of my activity bar?

Just go to res/values/styles.edit the xml file to change the color of action bar.


1 Answers

You can use React Native Status Bar(detailed description here). All you need to do is wrapping navigator with a view and adding a StatusBar component above it. Don't forget to import StatusBar from 'react-native' package.

<View>   <StatusBar     backgroundColor="blue"     barStyle="light-content"   />   <Navigator     initialRoute={{statusBarHidden: true}}     renderScene={(route, navigator) =>       <View>         <StatusBar hidden={route.statusBarHidden} />          ...       </View>     }   /> </View> 

One thing I've noticed is that you should style the parent View with flex:1, without it you'll just see a white blank screen. It's not mentioned in RN Documents though.

like image 171
eden Avatar answered Sep 22 '22 04:09

eden