简体   繁体   中英

React Native header bar

How can I configure the Android header bar background color similar to the ios with react native?

在此处输入图像描述

Thanks

You can use StatusBar ( https://reactnative.dev/docs/statusbar )

import { StatusBar } from 'react-native';
// ...
StatusBar.setBackgroundColor("#000000");

Use this

<StatusBar backgroundColor="yellow" />

For more info read this

Great Question!

You can use the react-native StatusBar tag:

Just do this:

import React, { Component } from 'react';
import { Platform, StyleSheet, View, StatusBar } from 'react-native';
import Constants from 'expo-constants';


class MyStatusbar extends Component {

    render() {
        return (
            <View style={styles.StatusBar}>
                <StatusBar translucent barStyle = "light-content" />
            </View>
        );
    }
}

const styles = StyleSheet.create({
    StatusBar: {
        height: Constants.statusBarHeight,
        backgroundColor: '#6a11cb'
    }
});

export default MyStatusbar;

and where you want the status bar use:

import MyStatusbar from './file-location'

and in the return(); :

<MyStatusbar />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM