React Native中的StatusBar颜色

Max*_*yuk 5 android statusbar react-native expo create-react-native-app

如何StatusBarreact-native不编辑Android特定文件的情况下更改组件的背景颜色?

Docs ,我可以使用backgroundColor财产.但它失败了.barStyle属性,setBarStyle&& setBackgroundColor静态方法也不能正常工作.

只有hidden财产有效.

我正在使用create-react-native-app,用Expo建造.

Ric*_*iao 7

在Expo App中,您需要app.json在项目根目录中进行编辑,如下所示:

{
    "expo": {
        "sdkVersion": "16.0.0",
        "androidStatusBar": {
            "barStyle": "dark-content",
            "backgroundColor": "#0A48A5"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

请参阅Expo文档:https: //docs.expo.io/versions/v16.0.0/guides/configuration.html

  • 它有帮助,但只能与`<StatusBar barStyle ="light-content"backgroundColor ="#1976D2"/>`结合使用.谢谢! (3认同)

Ant*_*amp 5

您可以使用

<StatusBar
 backgroundColor="blue"
 barStyle="light-content"
/>
Run Code Online (Sandbox Code Playgroud)

您可以在此处查看文档。