question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Header component height issue in android

See original GitHub issue

Hi I was trying to use the Header component in my app, the header component was working as expected in iOS but in Android I am getting status bar height along with the header component. Is there anyway to remove the status bar height from Android.

Here is the code snippet I have used:

<Header
            centerComponent={<Text>Title</Text>}
          rightComponent={
            <Image source={require('../../assets/images/navbar-logout.png')} />
          }
        />

Here is the result I am getting in Android and iOS:

screen shot 2018-01-10 at 8 25 41 pm

Versions: react-native-elements: ^0.18.5 react: 16.0.0 react-native: 0.51.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:21

github_iconTop GitHub Comments

13reactions
lFaustuscommented, May 10, 2019

this is what is did with the latest version import { StatusBar } from 'react-native'; <Header containerStyle={{ marginTop: ((StatusBar.currentHeight || 0) * -1) }} />

10reactions
iRoachiecommented, Jan 11, 2018

The height of the status bar is set as a fixed 70 units https://github.com/react-native-training/react-native-elements/blob/4f8225d91bd5917c88b3e70e27a991b12ad4dd1d/src/header/Header.js#L101

On iOS the statusBar overlaps the content, while on android it does not. An easy fix would be to set height for android to 70 - 24 in which 24 is the height of the status bar on android.

A quick workaround in your case would be to change the height of the StatusBar by using the outContainerStyles prop.

 outerContainerStyles={{height: Platform.OS === 'ios' ? 70 :  70 - 24}}

That way it’ll be 70 on iOS as expected and 56 on android

Read more comments on GitHub >

github_iconTop Results From Across the Web

(1.0.0) Header component height issue in android #1793
I was trying to use the Header component in my app, the header component was working as expected in iOS but in Android...
Read more >
programmatically retrieve Header component height - React ...
Header does not expose Height. I faced the same problem and I dove into the code, I realized Height is harcoded in this...
Read more >
min-height - CSS: Cascading Style Sheets - MDN Web Docs
The min-height CSS property sets the minimum height of an element. It prevents the used value of the height property from becoming smaller ......
Read more >
Stack Navigator | React Navigation
Stack Navigator provides a way for your app to transition between screens where each new screen is placed on top of a stack....
Read more >
Height and Width - React Native
A component can only expand to fill available space if its parent has dimensions greater than 0 . If a parent does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found