本文介绍了如何通过React Native在Android中找到状态栏的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过React Native在Android上找到状态栏的高度?
How can I find the height of the status bar on Android through React Native?
如果我检查 React.Dimensions
height,则该值似乎也包括状态栏的高度,但是我正尝试查找没有状态栏的布局高度.
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.
推荐答案
为此您不再需要任何插件,只需使用 StatusBar.currentHeight
:
You don't need any plugins for this (anymore), just use StatusBar.currentHeight
:
import {StatusBar} from 'react-native';
console.log('statusBarHeight: ', StatusBar.currentHeight);
显然,这似乎始终在Android上有效,但是在iOS上,最初确实返回了 undefined
:(
Apparently this does seem to work on Android always, but on iOS, initially undefined
is indeed returned :(
这篇关于如何通过React Native在Android中找到状态栏的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!