Mr. Robot
Mr. Robot

Reputation: 1824

Cannot change color of StatusBar in React Native Android

I am trying to change the background color of the status bar in my React Native Android app, but the API does not work in my case. Other props like hidden, barStyle, animated and translucent work fine but changing backgroundColor has no effect.

My code:

return (
    <>
        <StatusBar
            backgroundColor="#772ea2"
            barStyle="light-content"
            animated
            translucent={true}
        />
...

I am using React Native 0.63.3 and physical Android devices running Android 11 and 8.

Are there any other considerations I have to make in the code to make this work? How can it be fixed?

Upvotes: 0

Views: 637

Answers (1)

Mr. Robot
Mr. Robot

Reputation: 1824

The reason that it this prop didn't work was that I had this code in an Android style:

  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowTranslucentStatus">true</item> -->
  </style>

Upvotes: 3

Related Questions