Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find height of status bar in Android through React Native?

How can I find the height of the status bar on Android through React Native?

If I check the React.Dimensions height the value seems to include the status bar height too but I'm trying to find the height of the layout without the status bar.

like image 896
Zohar Levin Avatar asked Feb 16 '16 15:02

Zohar Levin


People also ask

What is the height of status bar in Android?

Official height is 24dp , as is stated officially by Google on Android Design webpage.

How do I make my status bar visible in react-native?

React Native StatusBar Props It is used to hide and show the status bar. By default, it is false. If hidden = {false} it is visible, if hidden = {true}, it hide the status bar. It sets the background color of the status bar.


1 Answers

You don't need any plugins for this (anymore), just use StatusBar.currentHeight:

import {StatusBar} from 'react-native'; console.log('statusBarHeight: ', StatusBar.currentHeight); 

EDIT: Apparently this does seem to work on Android always, but on iOS, initially undefined is indeed returned :(

like image 153
IjzerenHein Avatar answered Sep 23 '22 07:09

IjzerenHein