最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - reactnavigation hiding statusbar leaves space above header - Stack Overflow

programmeradmin0浏览0评论

I use reactnavigation and I am hiding the statusbar at the top, but it leaves an empty space above the header.

I already tried paddingTop or marginTop, but none work.

This is how I hide the statusbar.

import React from 'react';
import { Platform, View, StatusBar } from 'react-native';
import { Tabs, Drawer } from './config/router';

const App = () => (
    <View style={{flex:1}}>
        <StatusBar hidden={true} />
        <Drawer />
    </View>
);

export default App;

Any idea would be helpful.

Thanks.

I use reactnavigation and I am hiding the statusbar at the top, but it leaves an empty space above the header.

I already tried paddingTop or marginTop, but none work.

This is how I hide the statusbar.

import React from 'react';
import { Platform, View, StatusBar } from 'react-native';
import { Tabs, Drawer } from './config/router';

const App = () => (
    <View style={{flex:1}}>
        <StatusBar hidden={true} />
        <Drawer />
    </View>
);

export default App;

Any idea would be helpful.

Thanks.

Share Improve this question edited May 25, 2018 at 10:21 Neil Lunn 151k36 gold badges355 silver badges325 bronze badges asked May 25, 2018 at 9:15 udartsudarts 8881 gold badge10 silver badges30 bronze badges 1
  • Try by adding <StatusBar hidden/> in render method of your main screen. – Aditya Commented May 25, 2018 at 11:54
Add a ment  | 

2 Answers 2

Reset to default 5

How to Fix it

I add the following to the index.js:

import React from 'react';
import { Platform, View, StatusBar } from 'react-native';
import { Tabs, Drawer } from './config/router';
import { SafeAreaView } from 'react-navigation';

SafeAreaView.setStatusBarHeight(0);

const App = () => (
    <View style={{flex:1}}>
        <StatusBar hidden={true} />
        <Drawer />
    </View>
);

export default App;

Basically added the SafeAreaView part.

Hope this is helpful for others.

Try the static function Status Bar. You might need to convert the ponent to a React Component/Pure Component. Try it with and without converting it.

ponentDidMount(){
 StatusBar.setHidden(true,true);
}
发布评论

评论列表(0)

  1. 暂无评论